I have a table with this fields
id sell_date
a1 27/7/2012
a1 26/7/2012
a1 24/7/2012
a1 24/2/2012
I want a count of the months who has sells in a period of one year before the current date.
result
a1 = 2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need the datediff() function:
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_datediff
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_curdate