To find date difference in between two dates
DATEDIFF(exp1,exp2)
Function returns a value in day(s) from one date to other date.
exp1 and exp2 are either date or datetimestamp expressions.
exp2 subtracted from exp1 like(exp1-exp2). Only the date parts of the values are used in the calculation.
example:
SELECT id,name, datediff( Now( ) , enddate) AS Numofdays FROM `events` WHERE datediff( Now( ) , enddate) <30 LIMIT 0 , 30
Now() - Returns the datetimestamp 2007-12-21 10:05:42
enddate - date format like 2007-12-12
The above query will returns id,name and no of days who are all having day(s) as less than 30