October 6th, 2003, 02:54 PM
How to get last month data?
Is it posiible to get the last month data only with postgres SQL query.
For example, today is 2003-10-06, I just would like to get the data > 2003-09-06.
Thanks in advance
October 6th, 2003, 03:09 PM
Sure, just take a look at the timestamp / interval data types.
Not exactly sure what your table setup looks like but if you had a table named incident_event and the field evtdate as your timestamp you could do:
SELECT * FROM incident_event WHERE evtdate BETWEEN (now() - '1 month'::interval)::timestamp AND now()
PostgreSQL, it's what's for dinner...
October 6th, 2003, 03:55 PM