This tutorial explains how to use the MySQL DAYOFYEAR function with syntax and examples.
The MySQL DAYOFYEAR function returns day of the year for a date value.
The syntax for the DAYOFYEAR function in MySQL is:
DAYOFYEAR( date_value )
The date or datetime value from which to extract the day of year.
The DAYOFYEAR function can be used in the following versions of MySQL:
Let's look at some MySQL DAYOFYEAR function examples and explore how to use the DAYOFYEAR function in MySQL.
For example:
mysql> SELECT DAYOFYEAR('2014-01-01');
Output: 1
mysql> SELECT DAYOFYEAR('2014-02-28');
Output: 59
mysql> SELECT DAYOFYEAR('2014-12-31');
Output: 365
This last DAYOFYEAR example would display the day of the year for the current system date (current system date is returned by the CURDATE function).
mysql> SELECT DAYOFYEAR(CURDATE());