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:
SELECT id,
launched_timestamp
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?