Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

convert sysdate into GMT

Posted on 2009-07-15
5
Medium Priority
?
1,889 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 300 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

610 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