mysql - Check given date less than current_date -


I have an expiration date, I want to see if the end date is less than the present or not. And if the expiration date is before: 27-03-2011 I want to do some work if termination is over: there is no need to do anything on 27-04-2011.

I want to check one month after the end date and report the details for one month

field type

expdate date

Ex: 2012-01-20

Please use the MySQL date and time formats, They have the YYYY-MM-DD form (ISO date format). All MySQL dates and time functions work using this format.

MySQL also has date and time arithmetic. You can write expressions like "now () - interval 5 days", which is explained here

  root @ localhost [(none)]> gt; Now select (), now () - interval 5 days \ g ****** ********************************************************************************* ************** (now: 03-28 13:49:24 now () - interval 5 days: 49:24 1 line set (0.00 seconds)   

To list all items older than 5 days, / P>

  Select from made some selected WHERE & gt; There are some things to note about the name of the created column, which is not part of an expression: - INTERVAL 5 DAY   

or the same query

    • To create this fast, an index created must be present
    • To enable it to be used with an index, we have specially created 'Build & gt; Now () - Interval created 5 days 'no more' + Interval 5 days & gt; Now () '- This expression uses the column name created in an expression, so any index usage is not possible.
    • If you are using it to remove the query, then you are basically removing the old data from the left side of the time arrow, while inserting new data on the right hand of the time arrow. You may want to use the MySQL part and then Reese wants to use your table. This will allow you to delete the old data using the ALTER TABLE DROP PARTITION to throw the partition to say 5 days ago, to make new for tomorrow. It is much faster than in DELETE in many cases.

  • Comments