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

    Join Date
    Oct 2000
    Posts
    5
    Rep Power
    0
    how to delete from mysql which entry of database based on date?
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    Just use your date column in the where clause.

    DELETE FROM your_table WHERE date<NOW();

    DELETE FROM your_table WHERE date < NOW() - INTERVAL 5 DAYS;

    DELETE FROM your_table WHERE date < NOW() - INTERVAL 1 MONTH;

    Those will delete everything with a date column before now, before 5 days ago, and anything more than a month old.

    Look at the date and time functions in the MySQL manual to see all of the things to can do with dates.
    http://www.mysql.com/documentation/m...time_functions

    ---John Holmes...

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions...
    *
    * PHP Manual. www.php.net/manual
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter
    *************************************************************

Similar Threads

  1. mysql date time stamp and UTF8
    By doomish in forum MySQL Help
    Replies: 0
    Last Post: February 8th, 2004, 08:37 AM
  2. Select a mysql result date range with a drop down
    By horstuff in forum PHP Development
    Replies: 0
    Last Post: January 31st, 2004, 02:33 PM
  3. Unable to delete row from mysql table. Please help!
    By snkhan in forum PHP Development
    Replies: 1
    Last Post: January 24th, 2004, 09:47 PM
  4. PHP MySQL $result from delete statement unexpected
    By bvdzwaag in forum PHP Development
    Replies: 4
    Last Post: January 23rd, 2004, 08:44 AM
  5. Creating a unique id based on date infomation
    By A_lix in forum MySQL Help
    Replies: 1
    Last Post: January 9th, 2004, 04:53 PM

IMN logo majestic logo threadwatch logo seochat tools logo