#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    4
    Rep Power
    0

    How to get last month data?


    Hi All,

    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

    Scott
  2. #2
  3. Me likey breadsticks...
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2003
    Location
    Los Angeles
    Posts
    1,189
    Rep Power
    18
    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...
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    4
    Rep Power
    0

    Thanks it works great


    Thanks so much

IMN logo majestic logo threadwatch logo seochat tools logo