SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 GMT To PST
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Harish Vanama
Starting Member

India
3 Posts

Posted - 04/25/2014 :  02:45:57  Show Profile  Reply with Quote
I have a datetime field which is in GMT ,
1.i need to convert it into PST
2.Get the Date
3.Including day light savings

MuralikrishnaVeera
Posting Yak Master

India
106 Posts

Posted - 04/25/2014 :  04:56:21  Show Profile  Reply with Quote
Hello dude....I think you are from Orcle dataBase
so This may help you ....

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=28712


---------------
Murali Krishna

You live only once ..If you do it right once is enough.......
Go to Top of Page

MuralikrishnaVeera
Posting Yak Master

India
106 Posts

Posted - 04/25/2014 :  05:02:52  Show Profile  Reply with Quote
Suppose you have a timestamp column that is in GMT:

id-------datetime
1--------9/22/08 17:56
2--------9/16/08 21:25
3--------9/16/08 16:19

Then you can convert this time into PST (GMT+8hrs)just as below....

SELECT DATEADD(hh,8,datetime) AS datetimeinpst FROM Table

drrrrrrr.....From jhony



---------------
Murali Krishna

You live only once ..If you do it right once is enough.......
Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3695 Posts

Posted - 04/25/2014 :  08:44:00  Show Profile  Reply with Quote
The following will work for you and take into account daylight savings correctly. However, there are two important caveats:
a) Your system should be using Pacific time (i.e., getdate() should return pacific time).
b) You can't go back and do the conversion for dates that are in daylight savings period if you are currently in standard time period and vice versa.
SELECT DATEADD(hh,DATEDIFF(hh,GETUTCDATE(),GETDATE()),YourUtcDateColumn);
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000