Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert timestamp with timezone to date - new thread

Status
Not open for further replies.

vojvodina9i

Programmer
Nov 8, 2009
2
CA
thread759-289278

I was trying to convert Unix time to our local time, but using the method described in the thread759-289278 would give us the wrong result. For example, if we have ‘timestamp with the time zone’ variable that contains this value:
15-MAR-09 04.20.20.000000000 AM US/PACIFIC and we use to_char (or CAST or any other way to convert it to DATE), we are going to get the wrong result:
15-MAR-09 03.20.20.000000 AM US/PACIFIC.
By purpose, I chose the date when we obey Daylight Saving Time. For some reason, after the conversion, the system is loosing this one hour. I didn’t figure it way?
BTW, CAST doesn’t eliminate “time”. The time component is there, but depending on the format, might not be displayed. This is an example:
SELECT to_char(CAST(((FROM_TZ(CAST((to_date('19700101000000','YYYYMMDDHH24MISS') + NUMTODSINTERVAL( 1237116020, 'SECOND' )) AS TIMESTAMP), 'GMT')
AT TIME ZONE 'US/Pacific') ) as DATE), 'yyyy-mon-dd hh:mm:ss')
FROM DUAL;
And the result would be:
2009-mar-15 03:03:20. So the time is there.
 
For some reason, after the conversion, the system is loosing this one hour
Presumably, if you only specify the timezone as "US/Pacific", it assumes Pacific Standard Time. If you're using Pacific Daylight Time you need to say so explicitly.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
I think that our problem here is our Server, and the way how it deals with Daylight Saving Time. I think it is still converting between DST and ST (and back) by using old rules (before 2007).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top