SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Retrieve records 1 year before todays date

    Hi,

    I'm trying to retrieve all records from a table in my database that were posted(date_added column) anytime before 20 April 2009.

    I'd prefer not to store that date in particular, but today's date minus 1 year.

    I can currently restrict it to the past year using the following:
    ....date_added >= DATE_SUB( CURDATE( ) , INTERVAL 1 YEAR)....

    but I'd like to ignore those and go for previous posts.


    How would I be able to do this?



    Many thanks

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just change your >= operator to < (less than)
    Sam Hastings

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    1,285
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heheh. Just like that

    I think I had tried that initially, but put it on the wrong query. The pagination query.

    Many thanks SJH.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •