如何在MySQL中查找当年的天数 [英] How to find number of days in the current year in MySQL
本文介绍了如何在MySQL中查找当年的天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个问题,我想计算当年的天数.
有点像这样
I have this problem I want to calculate number days of the current year.
somewhat like this
SELECT DAYOFYEAR('2016-12-31');
Ans:366
但不提及日期
我试过了,但这给了我一年中的当前日期
but without mentioning the date
I tried this but it is giving me current day of the year
SELECT DAYOFYEAR(CURDATE());
请帮助
推荐答案
我敢肯定还有其他方法,但这很简单而且可行
I am sure there are other ways but this is simple and works
SELECT DAYOFYEAR(CONCAT(YEAR(NOW()),'-12-31')) AS days_in_year;
这篇关于如何在MySQL中查找当年的天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文