Introduction
Dealing with dates
Working with time data
Date and time date
18. Using date and time with constant values
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

Thanks for your help! Did you spot the mistake in the table?

The DATETIMEOFFSET data type is a very precise way to define a point in time. This is why using the equality sign (=) with this data type isn't a good idea. Two of these values may differ by a single nanosecond, and then the equality condition will not be satisfied. Nevertheless, you can use comparisons (i.e. >, <, !=, etc.) with DATETIMEOFFSET data to compare two columns, or a column with a constant value. Do we have to be very precise when providing the constant value? Not really. Take a look:

SELECT
  Id,
  LaunchedDatetime
FROM Flight
WHERE LaunchedDatetime > '2015-01-01';

As you can see, we compared a DATETIMEOFFSET with a simple date. How is this possible? Well, our database converts the date we provided to DATETIMEOFFSET by adding as many zeroes as necessary. For instance, '2015-01-01' will become '2015-01-01 00:00:00' and '2014-02-12 12:00' will become '2014-02-12 12:00:00'.

Convenient, isn't it?

Exercise

Find the ID number and discontinuation date for all aircraft discontinued after October 15, 2015.

Stuck? Here's a hint!

Remember about the proper date format, and use quotes: 'YYYY-MM-DD'.