How to compare dates in datetime fields in Postgresql?

后端 未结 4 787
太阳男子
太阳男子 2020-12-07 10:05

I have been facing a strange scenario when comparing dates in postgresql(version 9.2.4 in windows).
I have a column in my table say update_date with type \'timestamp w

4条回答
  •  粉色の甜心
    2020-12-07 10:29

    @Nicolai is correct about casting and why the condition is false for any data. i guess you prefer the first form because you want to avoid date manipulation on the input string, correct? you don't need to be afraid:

    SELECT *
    FROM table
    WHERE update_date >= '2013-05-03'::date
    AND update_date < ('2013-05-03'::date + '1 day'::interval);
    

提交回复
热议问题