问题
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