SQL GETUTCDATE
The SQL GETUTCDATE() function returns the current date and time in Coordinated Universal Time (UTC). This function is useful when you need to store or compare timestamps across different time zones to maintain consistency in applications.
In this tutorial, we will explore the GETUTCDATE() function, its syntax, and practical use cases with examples.
Syntax of SQL GETUTCDATE Function
The GETUTCDATE() function does not require any parameters. Its basic syntax is:
</>
Copy
SELECT GETUTCDATE();
Explanation:
- Returns the current date and time in UTC format.
- The output format is
YYYY-MM-DD hh:mm:ss.mmm(e.g.,2025-02-12 14:30:15.123). - It does not consider the server’s local time zone.
Step-by-Step Examples Using GETUTCDATE
1 Retrieving the Current UTC Date and Time
To fetch the current UTC date and time, use the following query:
</>
Copy
SELECT GETUTCDATE() AS current_utc_time;
Example Output:
