How to convert datetime fileds to UTC Datetime for existing data in the database?

138 views Asked by At

How can I change the Datetime values for the existing data to UTC Time? Is any inbuilt SQL qry available to change?

Eg. Existing Data in the table

CreatedON
2013-03-01 08:12:00.000
2013-03-01 13:15:18.000
2013-03-01 13:10:00.000

Need to convert this data to UTC time which is recorded as GMT Time during creation. Any suggestions will be helpful

1

There are 1 answers

5
vhadalgi On BEST ANSWER

try this:

declare @a datetime 
set @a='2013-03-01 08:12:00.000'

select  DateAdd(s,DateDiff(s, getdate(),getutcdate()),@a )