Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Dealing with dates
Working with time data
Date and time date
Extracting dates and times
Doing arithmetic with dates
Converting date and time data
Current date and time data
Building date and time data from parts
Summary and review

Instruction

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:

SELECT GETUTCDATE();

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.

Exercise

What's the hour difference between the launched time and the current UTC time for each aircraft? Show the IDs of the aircraft and the time difference; name the new column Hours. Order this info by the Hours column.