Date comparison in PostgreSQL
11,841
Yes, you can do that. Simple as that.
Have a look at the date
/ time
data types in PostgreSQL.
You may have to pay special attention if your "date", in fact, is a timestamp
. By default up to 6 fractional digits are saved, can be tricky with the equality operator. You might cast to timestamp(0)
to round to seconds or use date_trunc()
to truncate to one of various time units.
Author by
aeupinhere
Updated on June 04, 2022Comments
-
aeupinhere about 2 years
Is there a way to compare two dates in the same table like this:
SELECT * FROM mytable WHERE date_1 = date_2;
I am looking for the simplest approach to do this as part of an update statement.