Mohan
Mohan

Reputation: 31

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 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

Upvotes: 0

Views: 3452

Answers (1)

vbence
vbence

Reputation: 20333

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)

Upvotes: 2

Related Questions