user1857692 user1857692 - 7 months ago 13
SQL Question

Return all mySQL Records for Current Year

In mySQL, I would like to return a count of the records that have a

start_date
within the current year (as in the year 2012, NOT within the last one year time period) and (as a separate query) a count of the records from the previous year (2011 in the case as it is now).

My start dates are stored thus:
2012-12-02
. I am using PHP.

Help on how I would form these queries would be hugely appreciated.

Answer
SELECT COUNT(*)
 FROM TABLE1
 WHERE YEAR(START_DATE) = YEAR(CURDATE()); 
Comments