How do you select a date range in postgres?

后端 未结 2 607
借酒劲吻你
借酒劲吻你 2021-01-07 00:50

I have a timestamp field in a postgres database. I would like to select all dates that have happened within the last month. So something like select * from table where time

相关标签:
2条回答
  • 2021-01-07 00:59

    To be precise:

    SELECT *
    FROM   tbl
    WHERE  ts_col >  now() - interval '1 month'
    AND    ts_col <= now();
    
    0 讨论(0)
  • 2021-01-07 01:10
    select * from table where timestamp > now() - interval '1 month'
    
    0 讨论(0)
提交回复
热议问题