sql – 如何在Oracle中将日期转换为日期时间?

前端之家收集整理的这篇文章主要介绍了sql – 如何在Oracle中将日期转换为日期时间?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在oracle中有这个格式的日期DD-MM-YYY,我想用其他格式将它转换为日期时间DD-MM-YYY HH24:MI我该怎么办?

我试过这个,但没有任何工作:

to_date(the_date,'DD-MM-YYY HH24:MI')

还有这个:

to_date(to_char(date_debut_p),'DD-MM-YYY HH24:MI')

解决方法

i have a date in oracle with this format DD-MM-YYY and i want to convert it to datetime with this other format DD-MM-YYY HH24:MI

不,你很困惑. Oracle does not store dates in the format you see.内部存储7个字节,每个字节存储日期时间值的不同组件.

DATE数据类型始终具有日期和时间元素,精度为秒.

如果要显示,请使用TO_CHAR和正确的格式模型.

例如,

sql> select to_char(sysdate,'mm/dd/yyyy hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'MM
-------------------
11/25/2015 22:25:42
原文链接:https://www.f2er.com/mssql/75034.html

猜你在找的MsSQL相关文章