Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

oracle daylight savings

Posted on 2014-10-22
3
Medium Priority
?
415 Views
Last Modified: 2014-10-22
I am trying to conver the following epoch 1413902247 (2:37 pm on 10/21 in GMT therefre 10:37 am EST) to a date and time. My env is EST and I believe DST is in effect and we are -4 from GMT as of today (10/22/2014).
I have been tring various things below and can get the time. I cannot seem to get it converted to EST with daylight when I use EDT i get invalid timezone?


 SELECT CAST ((from_tz(CAST(to_Date('1970-01-01','YYYY-MM-DD') +1413902247/86400 AS TIMESTAMP),'EST') at TIME ZONE ('US/Eastern')) as DATE) --as EST
,from_tz(cast(to_Date('1970-01-01','YYYY-MM-DD') +1413902247/86400 AS TIMESTAMP),'US/Eastern') as EDT
       ,to_Date('1970-01-01','YYYY-MM-DD') +1413902247/86400 AS TIMESTAMP
--,                          to_char(new_time(to_date('1970-01-01','YYYY-MM-DD HH24:MI:SS') +1413902247/86400000) ,'EST','GMT'),'dd-mon-yyyy hh24:mi:ss') New_TimeGmtTime_DST
   FROM dual
0
Comment
Question by:pcomb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 40397449
SELECT (TIMESTAMP '1970-01-01 00:00:00 +00:00' + NUMTODSINTERVAL(1413902247, 'second'))
           AT TIME ZONE 'US/Eastern'
  FROM DUAL


US/Eastern is daylight savings aware, so it will return -04:00 in the DST period  and -05:00 in the Standard period
0
 

Author Comment

by:pcomb
ID: 40397459
perfect thanks
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 40397474
and, if you need to reverse it, then try one of these


SELECT   EXTRACT(DAY FROM i) * 86400
       + EXTRACT(HOUR FROM i) * 3600
       + EXTRACT(MINUTE FROM i) * 60
       + EXTRACT(SECOND FROM i)
  FROM (SELECT TIMESTAMP '2014-10-21 10:37:27 -04:00' - TIMESTAMP '1970-01-01 00:00:00 +00:00' i
          FROM DUAL);

SELECT   EXTRACT(DAY FROM i) * 86400
       + EXTRACT(HOUR FROM i) * 3600
       + EXTRACT(MINUTE FROM i) * 60
       + EXTRACT(SECOND FROM i)
  FROM (SELECT   FROM_TZ(TIMESTAMP '2014-10-21 10:37:27', 'US/Eastern')
               - TIMESTAMP '1970-01-01 00:00:00 +00:00'
                   i
          FROM DUAL);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to recover a database from a user managed backup
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question