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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 DateTime Convert to TimeZone

Author  Topic 

micnie_2020
Posting Yak Master

232 Posts

Posted - 2011-08-25 : 21:53:47
Dear All,

Is there a way for me to detect the datetime timezone? If UTC then no need to perform convert. If not then let's convert to UTC. How can i perform it?

Let said,

getDate()=> 2011-08-26 09:14:24.167
getUTCDate => 2011-08-26 01:14:24.167 (Converted Result suppose getting)


If the timezone is UTC 2011-08-26 01:14:24.167
Convert value will remain the same as 2011-08-26 01:14:24.167

Please advise.

Thank you.

Regards,
Micheale






visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-25 : 23:49:52
i think this would do

DECLARE @currdate datetime,@currUTCDate datetime

SELECT @currdate =GETDATE(),@currUTCDate=GETUTCDATE()
SELECT @currdate,@currUTCDate,DATEADD(ms,-DATEDIFF(ms,@currUTCDate,@currdate),@currdate)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -