Great! You know how to get current date and time. But what if you would like to get today's date and time data in UTC? T-SQL offers the
GETUTCDATE() function to do this. It's a lower-precision function, and it looks like this:
This will return today's UTC date and time according to the system time. It uses the
DATETIME data type. Let's look at an example of how we might use it to find a date three years in the future:
SELECT DATEADD(year, 3, GETUTCDATE());
This query gets the current date and time in UTC and adds 3 years to this date. It returns a new date that's exactly three years from now. As you notice, this date and time is in Coordinated Universal Time. Unless your time zone is UTC (i.e., Greenwich Mean Time),
GETUTCDATE() will return a different result than
GETDATE() or similar functions.