Convert UTC to local time in SQL Server

 Thanks to this StackOverflow answer:

convert(
    datetime, 
    switchoffset(
        convert(datetimeoffset, MyTable.UtcColumn), 
        datename(TzOffset, sysdatetimeoffset())
    )
) as ColumnInLocalTime

Comments

Popular posts from this blog

C# Record Serialization

Add timestamp to photo using ImageMagick

Read/write large blob to SQL Server from C#