Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to convert Epoch time to Datetime (YYYYMMDDHH24MMSS)

794703Aug 30 2010 — edited Aug 31 2010
Hi,


In our Oracle db, Datetime is stored as Epoch time (seconds since january 1st 1970). To get a readable date, I have converted those fields as followed:


TO_CHAR(TO_DATE('19700101000000', 'YYYYMMDDHH24MISS')+((DATE_FIELDS-18000) /(60*60*24)),'YYYYMMDDHH24MISS')

Result ex: 20100830135422


The problem is that the resulting fields are in VARCHAR2 instead of DATE so it causes issues in SAP BW reporting development. BW developpers can manage something to make it eventually work but I would like to correct this at the source if it is possible.

I have already tried to add another "TO_DATE" function at the beginning of the previous expression but I get a date in "DD-MMM-YY" format as a result even if I have forced another date format.

Any idea on how I could solve this?

Thanks a lot

Pascale
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 28 2010
Added on Aug 30 2010
17 comments
62,887 views