![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am having problems with getting dates out of Oracle since DST began. My problem is that I am converting an EPOCH date from seconds to the native Oracle DATE on the server |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Hi David, Using the number you retrieve for the epoch time, you can can derive the date, and then convert it from GMT to the time zone you want. You can use Oracle's new_time function, provided it supports your time zone. http://download-west.oracle.com/docs...tion.htm#78068 For example, let's say you retrieve a row where the epoch date is 1000000. Converting it to days gives you: SQL> select 1000000/(24*60*60) from dual; 1000000/(24*60*60) ------------------ 11.5740741 So, a little over 11 days past the 1st of January: SQL> select to_date('JAN-01-1970','MON-DD-YYYY')+(1000000/(24*60*60)) from dual; TO_DATE(' --------- 12-JAN-70 1* select to_char(to_date('JAN-01-1970','MON-DD-YYYY')+(1000000/(24*60*60)),'M ON-DD-YYYY HH:MI:SS AM') from dual SQL> / TO_CHAR(TO_DATE('JAN-01 ----------------------- JAN-12-1970 01:46:40 PM My timezone is currently EDT (GMT-4). So, using the new_time function, I can retrieve the date in a particular time zone and then convert it to a character representation, such as MON-DD-YYYY HH:MI:SS AM: SQL> select to_char(new_time(to_date('JAN-01-1970','MON-DD-YYYY')+(1000000/(24*60*60)),'GMT','EDT'),'MON-DD-YYYY HH:MI:SS AM') from dual; TO_CHAR(NEW_TIME(TO_DAT ----------------------- JAN-12-1970 09:46:40 AM Here's what happens if I try EST (-5) and PST (-8): SQL> select to_char(new_time(to_date('JAN-01-1970','MON-DD-YYYY')+(1000000/(24*6 0*60)),'GMT','EST'),'MON-DD-YYYY HH:MI:SS AM') from dual; TO_CHAR(NEW_TIME(TO_DAT ----------------------- JAN-12-1970 08:46:40 AM 1* select to_char(new_time(to_date('JAN-01-1970','MON-DD-YYYY')+(1000000/(24*6 0*60)),'GMT','PST'),'MON-DD-YYYY HH:MI:SS AM') from dual SQL> / TO_CHAR(NEW_TIME(TO_DAT ----------------------- JAN-12-1970 05:46:40 AM If the function doesn't include your time zone, you can still get the date in the format you want by adding the quotient of your time zone's gmt offset and 24. So, let's say I want to display a date in the Australian Eastern Standard Time format (GMT +10): 1* select to_char(to_date('JAN-01-1970','MON-DD-YYYY')+(1000000/(24*60*60))+(1 0/24),'MON-DD-YYYY HH:MI:SS AM') from dual SQL> / TO_CHAR(TO_DATE('JAN-01 ----------------------- JAN-12-1970 11:46:40 PM Is this what you're looking for? Regards, Arun |
#5
| |||
| |||
|
|
On Tue, 12 Apr 2005 15:15:00 GMT, David Sanabria david.sanabria (AT) morte_spam (DOT)....mortespam.com> wrote: I am having problems with getting dates out of Oracle since DST began. My problem is that I am converting an EPOCH date from seconds to the native Oracle DATE on the server What is your pressing need you are doing this? Oracle doesn't have it's own date at all, and just derives it from the system date. That said, on *Nix this would imply you have your TZ variable incorrectly set, and on Winblows you simply aren't using DST. Also please do not cross and multipost. Your audience won't be bigger, as the frequent responders monitor all three groups. -- Sybrand Bakker, Senior Oracle DBA |
#6
| |||
| |||
|
|
Two questions: 1) How can I verify the GMT offset that Solaris is using 2) Once #1 is known, what is the recommended course to address this issue (assumed to be: Change to correct TZ or offset). |
#7
| |||
| |||
|
|
I am having problems with getting dates out of Oracle since DST began. My problem is that I am converting an EPOCH date from seconds to the native Oracle DATE on the server and once I pull the data out through ODBC or ADO, the dates are getting set to GMT -5 rather than GMT - 4. I have tried the following: 1. Used Perl DBD::Oracle to retreive data: Success, dates not affected 2. ADO via VBScript 5.5: Failure. Times in April affset by -5 3. ADO via Crystal Reports 9 with latest service pack: Failure, dates in april offset by -5 4. ODBC via Crystal Reports: Failure. times ofset by -5 I am using Oracle 8.1.7.4. Oracle client version 9.2 and 10.1. ORacle ADO and MS ADO. Oracle ADO connects but times are wrong, MS ADO fails becuase it doesn't like CLOBS. I would apreciate any thoughts and suggestions. |
#8
| |||
| |||
|
|
I have attached my date conversion code (inline below) for the benefit of all Remedy users. If you can see anything within my code that might be a cause of our problems, please let me know. (otherwise, enjoy the code). |
#9
| |||
| |||
|
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |