PostgreSQL date comparison

Is there a way to compare two dates in the same table as follows:

SELECT * FROM mytable WHERE date_1 = date_2;

I am looking for the easiest way to do this as part of an update instruction.

+2
source share
1 answer

Yes you can do it. Just like that.

Look at the data types date/ timein PostgreSQL .

You may need to pay special attention if your "date", in fact, is timestamp. By default, up to 6 fractional digits are stored, which can be difficult with the equality operator. You can cast to timestamp(0)round to seconds, or use date_trunc()to truncate to one of various time units.

+4

All Articles