Oracle - Convert number 8 digit number to date

人盡茶涼 提交于 2019-12-24 00:58:48

问题


I have an oracle database where the dates are recorded as 8 digit number as for example:

59696580 which represent '01/07/2013  00:00:00'
59696610 which represent '01/07/2013  00:30:00'

Would someone know how to convert this 8 digit number into a date in Oracle SQL?

Thanks


回答1:


It might depend on the timezone, but looks like this number is the number of minutes since 12-30-1899 1:00:00, given the dates you want them to represent.

In order to get the date, you can just use the addition + operator to add a number of days to that base time. Given your number represents minutes, you can divide by 1440 to find out how many days do those minutes represent:

to_date('12-30-1899 1:00:00','MM-DD-YYYY HH24:Mi:SS') + (59696580/1440) 
to_date('12-30-1899 1:00:00','MM-DD-YYYY HH24:Mi:SS') + (59696610/1440) 

SQL Fiddle



来源:https://stackoverflow.com/questions/17543219/oracle-convert-number-8-digit-number-to-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!