Deals Of The Week - 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
19. Using date and time with constant values
Extracting dates and times
Timezone conversion
Format date and time
Current date and time data


Did you spot the mistake in the table? The timestamp data type is very precise in defining a point in time. This is why using the equal sign (=) with this data type isn't a good idea. Two of these values may differ by a single nanosecond, which means the equality condition wouldn't be satisfied.

Nevertheless, you can use comparisons (e.g., >, <, !=, etc.) with timestamp data. This will work when you're comparing two columns or when you're comparing one column against a constant value.

Do we have to be precise when providing a constant value? Not really. Take a look:

FROM aircraft
WHERE launched_timestamp > '2015-01-01';

As you can see, we compared a timestamp with a simple date. How is this possible? Well, our database converted the date we provided to a timestamp by adding as many zeros 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?


Find the ID number and withdrawn date for all aircraft discontinued after October 14, 2015.