If you need a more fractional seconds precision, use the SYSUTCDATETIME instead of GETUTCDATE()
Let's see the results when running some common date and time functions in SQL Server:
SELECT GETDATE() - 2009-03-28 13:08:37.553
SELECT SYSDATETIME() - 2009-03-28 13:08:37.5570000
SELECT GETUTCDATE() - 2009-03-28 07:38:37.557
SELECT SYSUTCDATETIME() - 2009-03-28 07:38:37.5570000
SELECT SYSDATETIMEOFFSET() - 2009-03-28 13:08:37.5570000 +05:30
As you can observe, the SYSDATETIME and SYSUTCDATETIME are used to display time with fractional second precision. The SYSDATETIMEOFFSET displays the time zone offset.
To find a difference between the Local time and UTC time use this query:
SELECT DATEDIFF(MINUTE,GetDate(),GetUTCDate());
Note: You may also want to checkout the SYSUTCDATETIME SWITCHOFFSET and TODATETIMEOFFSET functions
no comments please
ReplyDelete