i have to check the selected date from date picker.if the selected date is ex:2010.01.22 within one year it echo free service or it ended one year it echo cost service.its check 开发者_如何学编程with current date .how to do in query
I think the answer is:
SELECT (DATEDIFF(date_field, NOW()) > 365) as year_expired;
Note: this query does not take leap years into account
Update: I found a better method
SELECT (DATE_ADD(date_field, INTERVAL 1 YEAR) < CURDATE()) AS year_expired;
精彩评论