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

    Join Date
    Dec 1999
    Posts
    14
    Rep Power
    0
    My database has an expireing date column

    how can I select data based on current date
    against expiring date, something like:

    select * from $table
    where ??currentdate?? >= expiredate


    ------------------
  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
    Depending on the format of expiredate you can use curdate() or now().

    If expiredate is a timestamp(8) then you can use this where clause:

    where curdate()>=expiredate

    if expiredate is a timestamp(14) then you can use

    where now()>=expiredate
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    Annapolis, Maryland US
    Posts
    113
    Rep Power
    15
    Another example: say you have a two column table with an event name (event) and the date of that event in timestamp(8) format (event_date) and you wish to delete the events from the database that are more than 7 days old.

    delete from table_name where to_days(now()) - to_days(event_date) > 7;

    or

    select event from table_name where to_days(now()) - to_days(event_date) = 7; // select last week's events

    the to_days() function works on date and timestamp data types and returns the number of days since year 0 -> 1 A.D., 1 B.C. or somewhere around there


    [This message has been edited by Kyuzo (edited January 14, 2000).]

Similar Threads

  1. mySQL and Win2k aborted connection crash
    By SDFiero in forum MySQL Help
    Replies: 3
    Last Post: September 28th, 2002, 09:29 PM
  2. how to check the date and compare the day ?
    By thenewuser in forum PHP Development
    Replies: 1
    Last Post: December 22nd, 2001, 01:02 PM
  3. PHP date check
    By Inch in forum PHP Development
    Replies: 1
    Last Post: December 11th, 2001, 04:11 AM
  4. date check
    By tchick in forum HTML Programming
    Replies: 4
    Last Post: November 29th, 2001, 06:11 AM
  5. Replies: 5
    Last Post: November 23rd, 2000, 08:48 AM

IMN logo majestic logo threadwatch logo seochat tools logo