Solved

convert sysdate into GMT

Posted on 2009-07-15
5
1,818 Views
Last Modified: 2013-12-19
How do we convert the sysdate to GMT format.
select dbtimezone does give us the GMT offset and not the literal 'time zone'
This makes using 'to_char(new_time(entry_date, 'EST', 'CST')' kind of approach impossible - as it does not accept offsets.

How then do we get the 'TZ' of the database - alternatively how do we convert the sysdate into GMT.
0
Comment
Question by:ranadhir
[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
  • 3
5 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 24861528
I recommend NOT using dbtimezone.

Oracle recommends it only ever be set to +0:00
if you want times with timezones

use systimestamp instead of sysdate


0
 
LVL 74

Accepted Solution

by:
sdstuber earned 75 total points
ID: 24861576
try this....

SELECT
       SYSTIMESTAMP,
       SYSDATE local_sysdate,
       SYSDATE - EXTRACT(TIMEZONE_HOUR FROM SYSTIMESTAMP) / 24 gmt_sysdate
FROM   DUAL
0
 

Author Comment

by:ranadhir
ID: 24866541
this works great - thanks
 just one question since you advised against dbtimezone.

Given a time zone region is it fine to V$TIMEZONE_NAMES in my PL/SQL to get teh corresponding TZ abbrev.
Also,given a off-set is there a way to get the corresponding TZ?
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 24866584
There is no reliable way to go from an offset to an abbreviation using ONLY the offset as your input information
because an offset can have multiple meanings from observation of Daylight Saving Time and/or regional abbreviations.

EST and CDT have the same offset (-5)   (Easter Standard vs Centeral Daylight)  - daylight observation
EDT and ECT have the same offset (-4)  (Eastern Daylight vs Eastern Caribbean) - daylight observation and region

You can build your own lookup table of abbreviations and offsets that map 1-to-1.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

707 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