Best April deals - hours only!Up to 80% off on all courses and bundles.-Close
Dealing with dates
Working with time
Date and time data types in PostgreSQL
20. Using operators to compare timestamps
Extracting dates and times
Timezone conversion
Format date and time
Current date and time data


Well done! Next, let's see what kind of operators we can use to compare timestamp data. This query ...

FROM aircraft
WHERE registration_timestamp >= '2010-01-01';
  AND registration_timestamp <  '2016-01-01'

... displays the ID of aircraft where the registration date is within the years 2010 – 2015. Briefly, these are the operators you can use with date and time data:

  • < – less than.
  • > – greater than.
  • <= – less than or equal to.
  • >= – greater than or equal to.

Remember that because of the high precision of timestamp data, it's a bad idea to use an equality operator (=).


Show the id and launched_timestamp columns for aircraft where the launched_timestamp is more than '2010-12-31 23:00:00' and less than '2015-01-01 12:00:00'.

Stuck? Here's a hint!

You'll need this condition:

WHERE launched_timestamp > '2010-12-31 23:00:00'
  AND launched_timestamp < '2015-01-01 12:00:00'