Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Dates
Time
Timestamps
18. Timestamps with constant values
Extract functions
Timezone conversion
Intervals
Current date and time
Review

Instruction

We detected a mistake in the table, thank you for your help.

Timestamps are a very precise way to define a point in time. This is why using the equality sign (=) with them isn't a good idea. Two timestamps may differ by a single second and the condition on equality will not be satisfied. Still, you can use comparisons with >, <, != etc. to compare two columns (just as you did) or a column compared to a constant value. Do we have to be very precise when providing the constant value? Not really. Take a look:

SELECT
  id,
  launched
FROM flight
WHERE launched > '2015-01-01';

As you can see, we compared a timestamp with a date. How is this possible? Well, our database converts the date we provided to a timestamp by adding as many zeroes as necessary. For instance:

  • '2015-01-01' will become '2015-01-01 00:00:00',
  • '2014-02-12 12:00' will become '2014-02-12 12:00:00'.

Convenient, isn't it?

Exercise

Identify the id and withdrawn date for all the aircraft withdrawn after October 15, 2015. The column names should be id and withdrawn.

Stuck? Here's a hint!

Remember the proper date format and use apostrophes: 'YYYY-MM-DD'.