GETUTCDATE() Function in SQL Server


The GETUTCDATE() function in SQL Server returns the current UTC date and time. UTC stands for Coordinated Universal Time, which is the primary time standard by which the world regulates clocks and time.

Syntax:

GETUTCDATE()

Example:

SELECT GETUTCDATE() AS CurrentUTCDateTime

Output:

CurrentUTCDateTime
-----------------------
2021-10-20 10:30:45.123

Another example to use GETUTCDATE() function to get the difference between UTC and local time:

SELECT DATEDIFF(HOUR, GETUTCDATE(), GETDATE()) AS UTCToLocalTimeDifferenceInHours

Output:

UTCToLocalTimeDifferenceInHours
-------------------------------
-7

This means that the local time is 7 hours behind the UTC time.



About the author

William Pham is the Admin and primary author of Howto-Code.com. With over 10 years of experience in programming. William Pham is fluent in several programming languages, including Python, PHP, JavaScript, Java, C++.