Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Trying to get the UTC time out of ORACLE
I thought this would be rather simple... At first anyway.
I was originally going to use this function
FUNCTION GETUTC RETURN TIMESTAMP AS tsUTC TIMESTAMP;
BEGIN tsUTC := SYS_EXTRACT_UTC(SYSTIMESTAMP);
RETURN(tsUTC);
END GETUTC; From the docs that looked like it would work, and when I checked SYSTIMESTAMPs information for Today I Got 26-FEB-03 10.54.38.968000000 AM -05:00 <-- Correct offset FOR EST
When I set it to after DST would be in effect I got this...
06-APR-03 03.00.27.515000000 AM -04:00 <-- Correct Offset for EDT
Ok so far so good...
However the Result of SYS_EXTRACT_UTC(SYSTIMESTAMP) was an hour off for EDT as if it was still using -05:00 time zone information.
So When I Called SYS_EXTRACT_UTC(SYSTIMESTAMP) from today I got
02/26/2003 04:06:14.14 PM (Which is right for a base time of 11:06:14.14 AM EST) Then I moved the time forward to June 26th and got this as my result
06/26/2003 04:07:19.19 PM (Which is off by an hour it should be 3:07:19.19 PM with a base time of 11:07:19.19 AM EDT)
At first I thought maybe some of the info was being pulled from the Windoze registry and the registry wasn't being updated so I let the time roll over DST and saw the clock change. Alas no change in the results of SYS_EXTRACT_UTC(SYSTIMESTAMP); as it was an hour off for EDT
I even tried this
SYS_EXTRACT_UTC(TO_CHAR(SYSTIMESTAMP, 'DD-MON-YYYY HH:MI:SS.SS AM
TZH:TZM')));
No Dice even though
TO_CHAR(SYSTIMESTAMP, 'DD-MON-YYYY HH:MI:SS.SS AM TZH:TZM')
Showed the time zone as -4:00 WHEN in EDT and -5:00 in EST the
SYS_EXTRACT_UTC still gave the wrong result for EDT off by 5 hours instead
of 4
I am sure I am missing something here and it can't be this hard to get UTC time from an ORACLE Database. So can anyone tell me what it is I am missing?
We are developing on Oracle 9i on Windoze 2000 AS SP3
Thanks for any help,
Regards,
Bill
Received on Wed Feb 26 2003 - 10:23:56 CST