摘要:
下文讲述MySQL数据库中获取指定日期在年度第几天的方法分享,如下所示;
实现思路:
采用DAYOFYEAR(date)
----------参数说明---------
date:
待检索日期
----------返回值说明-------
返回当前日期为本年度的第几日
(此返回值为一个1~366的值)
例:
mysql> select dayofyear('20200905');
+-----------------------+
| dayofyear('20200905') |
+-----------------------+
| 249 |
+-----------------------+
1 row in set (0.00 sec)
mysql> select dayofyear('20200805');
+-----------------------+
| dayofyear('20200805') |
+-----------------------+
| 218 |
+-----------------------+
1 row in set (0.00 sec)
mysql> select dayofyear('20200831');
+-----------------------+
| dayofyear('20200831') |
+-----------------------+
| 244 |
+-----------------------+
1 row in set (0.00 sec)