Solved

oracle daylight savings

Posted on 2014-10-22
3
393 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
  • 2
3 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 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 73

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Oracle 12c 10 100
statspack purge automate 7 29
query in Oracle forms Builder 2 27
Wrap Oraccle SQL*Plus executable Command 4 35
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now