'Get OffSet part from SYSDATETIMEOFFSET()
Hi try to get the offset part from the result of the function SYSDATETIMEOFFSET();
For example, I need -04:00 part of the result: 2014-03-21 11:13:14.7405400 -04:00
Is there a way the "split" a query result in MS SQL?
Thanks
Solution 1:[1]
DECLARE @timeStr NVARCHAR(50) = CAST(SYSDATETIMEOFFSET() AS NVARCHAR(50))
SELECT RIGHT(@timeStr, 6)
Solution 2:[2]
Solution 3:[3]
I had a similar problem I needed the offset only from a file created datetime for sending a transaction file. I used:
SELECT ((DATEPART (TZOFFSET, SYSDATETIMEOFFSET()))/60*100)
Solution 4:[4]
Necro answer, but its a top google result. I wanted the hour part:
select FORMAT(SYSDATETIMEOFFSET(),'zzz')
Results in a result of -06:00 for a server in CST timezone
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ram |
| Solution 2 | Ram |
| Solution 3 | Benjamin W. |
| Solution 4 | Wayne Evans |
