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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With