#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    145
    Rep Power
    15
    I have a database that uses two date fields for tracking information. The first field is for the addition of the record and the second is for the expiration.

    I have a small section that I want to list records that will expire in the current week (or for that matter in the next 7 or 14 days). What is the syntax that I would use to call mySQL with to get that info.

    Any help would be great.

    mediaworks
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Check the syntax in the mysql manual, but this should be close:

    $query="select * from tablename where expiredate>now() and subdate(expiredate,interval 7 day)<now()";

    This will pull all records that expire between now and 7 days from now. Just change the 7 to 14 or whatever.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    145
    Rep Power
    15
    Thank you - that worked like a <charm>! :-)

Similar Threads

  1. Selecting rows from up to a week back
    By jwhoisthebest in forum MySQL Help
    Replies: 1
    Last Post: January 30th, 2004, 06:43 AM
  2. Deleting unreferenced rows in SQL
    By howard.cole in forum MySQL Help
    Replies: 5
    Last Post: January 26th, 2004, 10:10 AM
  3. SQL Query question (Joining tables with missing rows)
    By LiquidKernel in forum MySQL Help
    Replies: 4
    Last Post: January 17th, 2004, 10:20 PM
  4. Poor SQL Server Programming, Part 4
    By DavidM in forum MS SQL Development
    Replies: 0
    Last Post: October 21st, 2003, 10:28 PM
  5. Poor SQL Server Programming Part 2
    By DavidM in forum MS SQL Development
    Replies: 0
    Last Post: October 20th, 2003, 10:19 PM

IMN logo majestic logo threadwatch logo seochat tools logo