Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 GMT To PST

Author  Topic 

Harish Vanama
Starting Member

3 Posts

Posted - 2014-04-25 : 02:45:57
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

129 Posts

Posted - 2014-04-25 : 04:56:21
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

129 Posts

Posted - 2014-04-25 : 05:02:52
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
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-04-25 : 08:44:00
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
   

- Advertisement -