MySQL DAYOFYEAR() function
DAYOFYEAR() function
MySQL DAYOFYEAR() returns day of the year for a date. The return value is within the range of 1 to 366.
This function is useful in -
- DAYOFYEAR() is used to categorize, analyze, and visualize data based on the day of the year.
- It's valuable for understanding trends or variations that occur on specific days within a year.
- For tasks that involve tracking events or patterns that are seasonally significant, DAYOFYEAR() helps identify and analyze those specific days.
- DAYOFYEAR() is useful for identifying the position of cyclical events within a year, such as holidays, anniversaries, or natural phenomena.
- DAYOFYEAR() aids in financial analysis that considers the timing of events, such as tracking revenue patterns or interest payments.
- For calculating durations or intervals within a year, DAYOFYEAR() provides the numeric value representing the day's position.
Syntax:
DAYOFYEAR(date1)
Where date1 is a date.
Syntax Diagram:
MySQL Version: 8.0
Pictorial Presentation:
Example: MySQL DAYOFYEAR() function
The following statement will return the day of the year from the given date 2008-05-15.
Code:
SELECT DAYOFYEAR('2008-05-15');
Output:
mysql> SELECT DAYOFYEAR('2008-05-15'); +-------------------------+ | DAYOFYEAR('2008-05-15') | +-------------------------+ | 136 | +-------------------------+ 1 row in set (0.00 sec)
Video Presentation:
All Date and Time Functions:
Click here to see the MySQL Date and time functions.
Previous: DAY OF WEEK()
Next: EXTRACT()
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/mysql/date-and-time-functions/mysql-dayofyear-function.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics