SQLTeam.com | Weblogs | Forums

Date timzone conversion


#1

the datetime value coming from source is in CET .( but doesnt contain time zone in the value).

I need to convert that into GMT .

How would i write it ?


#2

Starting with sql server 2016, you can use AT TIME ZONE

declare @dt2_myDate as datetime2(0) = '20190216 08:10:12' ;

select  CONVERT(datetime2(0) , @dt2_myDate , 126)  
                AT TIME ZONE 'Central European Standard Time' 
                AT TIME ZONE 'UTC' as newDateTime

output:

newDateTime
16/02/2019 07:10:12 +00:00

dbfiddlehere


#3

Thanks from reply. The output should be in datetime format . It hasn’t an extra offset information