英文:
How to add three zeroes to the end of a datetime string in Oracle?
问题
我有这样的数据 2020/08/05 05:34:05.000,我尝试使用 to_char(column,'YYYY/MM/DD HH24:MI:SS.FF3') 来获得类似的输出,但出现了错误 "日期格式无法识别"。如何在秒后附加这些000?
我尝试使用 to_char(column,'YYYY/MM/DD HH24:MI:SS'),它给我 2020/08/05 05:34:05,但我想要在末尾附加三个零,是否可以在不硬编码零的情况下实现?
英文:
I have data like this 2020/08/05 05:34:05.000 i tried to get the similar output by using to_char(column,'YYYY/MM/DD HH24:MI:SS.FF3') getting error "Date format not recognized". how to append these 000 at the end after seconds ?
I tried using to_char(column,'YYYY/MM/DD HH24:MI:SS') which gives me 2020/08/05 05:34:05 but i want three zeroes should append at the end is it possible without hardcoding zeroes to get the 000 ?
答案1
得分: 1
看起来列的数据类型是 DATE。 DATE 数据类型不支持小数秒,但你可以将其转换为 TIMESTAMP。
to_char(CAST(column AS TIMESTAMP), 'YYYY/MM/DD HH24:MI:SS.FF3')
英文:
Looks like the column datatype is DATE. DATE datatype does not support fractional seconds but you can cast it into a TIMESTAMP.
to_char(CAST(column AS TIMESTAMP), 'YYYY/MM/DD HH24:MI:SS.FF3')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论