如何获取日期数

时间:2017-07-13 04:44:25

标签: mysql fetch datediff days

我有一些问题,我有两个日期选择日期,然后我想知道两个日期之间的日期范围。

DATEDIFF('2017-04-30','2017-04-01')
Result : 29

输出:

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,
18,19,20,21,22,23,24,25,26,27,28,29,30

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我创建了一个表调用tblCalendar(日历),然后我只需要进行查询

SELECT 
GROUP_CONCAT( DATE_FORMAT(calender, '%d')) ResultDate 
FROM 
calender 
WHERE 
calender BETWEEN '2017-04-01' AND '2017-04-30'

结果:

01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30