Tuesday, July 28, 2015

SQL to convert GMT to EST with Daylight Savings

SELECT to_date(
           to_char(
             to_timestamp_tz(
               to_char(to_timestamp('2015-11-01 06:00:00','yyyy-mm-dd hh24:mi:ss'),'YYYYMMDDHH24:MI:SS')||' '||'GMT'
                            ,'YYYYMMDDHH24:MI:SS TZR') at time zone 'America/New_York'
                   ,'YYYYMMDDHH24:MI:SS')
                 ,'YYYYMMDDHH24:MI:SS') datelight_GMT_EST
  FROM DUAL