简体   繁体   English

Oracle Sql将短日期转换为字符串或长日期

[英]Oracle Sql convert FROM short date TO string or long date

I'm reading a column that's a short date that I need to convert to a long date or a string. 我正在读一个我需要转换为长日期或字符串的短日期列。 Excel can do this readily , but I can't find out how to do it with Oracles SQL Excel可以很容易地做到这一点,但我无法找到如何使用Oracles SQL做到这一点

Examples of the DATETIME column: DATETIME列的示例:

41590.6753233101
41593.7843996875
41593.7844002199
41593.7844007638

I would like to convert this to a human readable date. 我想将此转换为人类可读日期。 Hate to have to direct someone move the out put to excel if you want to see the date. 如果你想查看日期,讨厌必须指示有人将ex out移出去。

Excel stores dates as the number of days since January 1, 1900, so to convert an Excel date, you just add them. Excel将日期存储为自1900年1月1日以来的天数,因此要转换Excel日期,只需添加它们即可。

with mydates as (select 41590.6753233101 as datetime from dual
    union select 41593.7843996875 from dual
    union select 41593.7844002199 from dual
    union select 41593.7844007638 from dual)
select datetime, DATE '1899-12-30' + datetime
from mydates;

Output: 输出:

41590.6753233101    11/12/2013 4:12:28 PM
41593.7843996875    11/15/2013 6:49:32 PM
41593.7844002199    11/15/2013 6:49:32 PM
41593.7844007638    11/15/2013 6:49:32 PM  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM