Get current GMT Time in Oracle and MSSQL
Posted on 5/14/2008 3:05:58 AM
in #SQL SERVER
Hi,
Many a time with all the data we want to store the current date time for reference purpose. If your application is going to work with more than one country than its best to store the date time in UTC (GMT) format. With difference database the way to get the current UTC date time is different. Here is a list of way to do the same for different database.
Oracle 9i and above
select new_time(sysdate,'EST','GMT') into Result from dual;
Don’t forget to change EST with the current time zone of the database.
MS SQL 200 and above
GETUTCDATE()
Remember MS SQL also has GETDATE() function. But the GETDATE() function does not give the UTC (GMT) date time.
Vikram
|
Posted on 5/25/2008 10:03:44 PM
Hi,
I find your url from forums.asp.net
This statement "select new_time(sysdate,'EST','GMT') into Result from dual;" does not work, but when changed to
"select new_time(sysdate,'EST','GMT') from dual;" executes perfectly. I am using oracle 10.2.
Could you plz tell me where is the problem
"
|
Posted on 8/6/2008 5:38:04 AM
Your method to get Oracle UTC date is wrong (only works for Eastern Standard...).
What you should do :
select cast(sys_extract_utc(systimestamp) as date) from dual;
|