Reputation: 91
I need my query to select all dates between the first date of this year and the present date. (ie all dates in database within this year), however my code does this but for the last 12 months. How can i alter my code to ensure its only dates from this year?
WHERE DATE_SUB(CURDATE(), INTERVAL 1 YEAR) <= date
Many Thanks
Upvotes: 1
Views: 873
Reputation: 3332
where created_date between MAKEDATE(YEAR(now()), 1) and now();
MAKEDATE(YEAR(now()), 1) gives you '01/01/(thisyear)'
Upvotes: 1
Reputation: 263733
SELECT ...
FROM ...
WHERE DATE_SUB(CURDATE(), INTERVAL 1 YEAR) <= date AND
YEAR(your_datecolumn) = YEAR(CURDATE())
Upvotes: 2