Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to SELECT the UTC offset from a DateTimeOffset object?

I am currently using:

SELECT DATEPART(TZ, SYSDATETIMEOFFSET())

However, it returns the offset in minutes. I would like to preserve the format of '-05:00' instead of '-300'

Thank you.

like image 806
K M Avatar asked Dec 15 '22 15:12

K M


1 Answers

In MS SQL Server you can also use

SELECT DATENAME(tz, SYSDATETIMEOFFSET())

which will return a nvarchar with the offset

screenshot of the excecution result

like image 87
Wowe Avatar answered Mar 02 '23 19:03

Wowe