How can I get the result of the current year using SQL?
I have a table that has a column date with the format yyyy-mm-dd
.
Now, I want to do select query that only returns the current year result.
The pseudo code should be like:
select * from table where date is (current year dates)
The result should be as following:
id date 2 2015-01-01 3 2015-02-01 9 2015-01-01 6 2015-02-01
How can I do this?
Use YEAR()
to get only the year of the dates you want to work with:
select * from table where YEAR(date) = YEAR(CURDATE())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With