简体   繁体   中英

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

Examples of the DATETIME column:

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.

Excel stores dates as the number of days since January 1, 1900, so to convert an Excel date, you just add them.

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  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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