SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Delete data after 1 month

    Hi...

    I have form of uploading data to the database, but I need to delete data after 1 month. how does it possibe.

    here is my query of insert data to the database:

    Code:
    $sql = "INSERT INTO sales_order (ProductType,WorkOrder,POIssueDate,SalesMonth) 
          VALUES 
          ('$ProductType','$WorkOrder','$POIssueDate','$SalesMonth')
          ON DUPLICATE KEY UPDATE
          ProductType = '$ProductType', WorkOrder = '$WorkOrder', POIssueDate = '$POIssueDate', SalesMonth = '$SalesMonth'" or die(mysql_error());
          mysql_query($sql, $con);
    Should I need to add fields for date upload?

    Thank you

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2010
    Location
    Perundurai, Tamilnadu, India
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you can add new field date_created, then it will be easy for you to delete the data after 1 month.
    Or use POIssueDate, here is sample query to delete the records older than a month.

    Code:
    delete from sales_order where POIssueDate <= date_sub(curdate(), interval 1 month)


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
  •