Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Dealing with dates
Working with time
14. Comparing dates and times using operators
Date and time data types in PostgreSQL
Extracting dates and times
Timezone conversion
Format date and time
Current date and time data


Well done! You can use the following operators to compare time data:

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

Look at this query:

FROM route
WHERE arrival_time >= '12:00:00'
  AND arrival_time <= '15:00:00';

It displays the codes and arrival times only for routes where the arrival time is at least 12:00:00 and not after 15:00:00.


Show the code and departure time for all routes where the departure time is later than 14:00:00 but earlier than 23:00:00.

Stuck? Here's a hint!

Use the following expression:

WHERE departure_time < '23:00:00'
  AND departure_time > '14:00:00'