check expiry date for one month interval only
I have expiry date in my table.
Example : if the current date is ex:27-03-2011. I want to Generate chart if the expiry date is 27-02-2011. I want to check and generate the chart for 开发者_JS百科only one month of the expiry date , After one month of the expiry date i dont want to check
algorithm :
if(CurrentDate > ExpiryDate && CurrentDate < 1-month-from-expiry)
{
GenerateChart();
}
else
{
//Don't do anything
}
how to do this in query
table1
field type
expdate date
Ex:2012-01-20
As I understand you want a list of records which have expired in the last month:
SELECT * FROM table WHERE ExpiryDate < NOW() AND ExpiryDate > DATE_ADD(NOW() INTERVAL -1 MONTH)
精彩评论