我必须从表的日期列中选择值2019-03-25,但格式如下:
2019-03-25T00:00:00.000+02:00
我能得到吗?
Oracle 10g
谢谢!
答案 0 :(得分:0)
date
数据类型不存储毫秒和时区信息,因此我理解了您的问题,即如何将date
格式化为具有固定值的毫秒和时区的目标格式。
如果是这样,您可以像这样使用to_char()
:
to_char(mycol, 'yyyy-mm-dd"T"hh24:mi:ss".000+2:00"')
答案 1 :(得分:0)
您可以将class MyThread(QtCore.QThread):
def __init__(self, scene):
super().__init__()
self.scene = scene
def run(self):
for item in self.scene.items():
# Render the ROI item to create a rasterized mask.
qimage = self.qimage_from_shape_item(item)
# do some stuff
@staticmethod
def qimage_from_shape_item(item: QtWidgets.QAbstractGraphicsShapeItem) -> QtGui.QImage:
# Get items pen and brush to set back later.
pen = item.pen()
brush = item.brush()
# Remove pen, set brush to white.
item.setPen(QtGui.QPen(QtCore.Qt.NoPen))
item.setBrush(QtCore.Qt.white)
# Determine the bounding box in pixel coordinates.
top = int(item.scenePos().y() + item.boundingRect().top())
left = int(item.scenePos().x() + item.boundingRect().left())
bottom = int(item.scenePos().y() + item.boundingRect().bottom()) + 1
right = int(item.scenePos().x() + item.boundingRect().right()) + 1
size = QtCore.QSize(right - left, bottom - top)
# Initialize qimage, use 8-bit grayscale.
qimage = QtGui.QImage(size, QtGui.QImage.Format_Grayscale8)
qimage.fill(QtCore.Qt.transparent)
painter = QtGui.QPainter(qimage)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
# Offset the painter to paint item in its correct pixel location.
painter.translate(item.scenePos().x() - left, item.scenePos().y() - top)
# Paint the item.
item.paint(painter, QtWidgets.QStyleOptionGraphicsItem())
# Set the pen and brush back.
item.setPen(pen)
item.setBrush(brush)
# Set the pixel coordinate offset of the item to the QImage.
qimage.setOffset(QtCore.QPoint(left, top))
return qimage
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
widget = QtWidgets.QWidget()
layout = QtWidgets.QVBoxLayout(widget)
view = QtWidgets.QGraphicsView()
layout.addWidget(view)
scene = QtWidgets.QGraphicsScene()
view.setScene(scene)
thread = MyThread(scene)
view.setFixedSize(400, 300)
scene.setSceneRect(0, 0, 400, 300)
rect_item = QtWidgets.QGraphicsRectItem()
p = QtCore.QPointF(123.4, 56.78)
rect_item.setPos(p)
r = QtCore.QRectF(0., 0., 161.8, 100.)
rect_item.setRect(r)
scene.addItem(rect_item)
button = QtWidgets.QPushButton("Get masks")
layout.addWidget(button)
button.clicked.connect(thread.start)
widget.show()
sys.exit(app.exec_())
CAST
改成DATE
,然后使用TIMESTAMP
设置时区,然后使用FROM_TZ
将其格式化为您的要求:
TO_CHAR
其中,为您的示例数据:
SELECT TO_CHAR(
FROM_TZ( CAST( your_date AS TIMESTAMP ), '+02:00' ),
'YYYY-MM-DD"T"HH24:MI:SS.FF3TZH:TZM'
) AS formatted_date
FROM your_table;
输出:
| FORMATTED_DATE | | :---------------------------- | | 2019-03-25T00:00:00.000+02:00 |
db <>提琴here
答案 2 :(得分:0)
我们无法在db中存储时区信息,这就是为什么我们可以简单地使用以下格式的原因,
{{1}}