MySQL列出某个月或是已知日期范围内的所有日期
set @mycnt = 0;
select date_add("2008-07-31",interval @mycnt :=@mycnt + 1 day) as day from t_prehandle_qeesoo_04 limit 31
上面这个SQL就可以列出8月份所有日期。
上面SQL里的2008-07-31指的是起始日期,limit 31 是指加31天。
t_prehandle_qeesoo_04是随便一个表,只要这个表有31行以上数据就行。
结果:
day
2008-08-01
2008-08-02
2008-08-03
2008-08-04
2008-08-05
2008-08-06
2008-08-07
2008-08-08
2008-08-09
2008-08-10
2008-08-11
2008-08-12
2008-08-13
2008-08-14
2008-08-15
2008-08-16
2008-08-17
2008-08-18
2008-08-19
2008-08-20
2008-08-21
2008-08-22
2008-08-23
2008-08-24
2008-08-25
2008-08-26
2008-08-27
2008-08-28
2008-08-29
2008-08-30
2008-08-31
相关推荐
xuanlvhaoshao 2020-05-07
militala 2020-01-13
cjylean 2019-12-04
tanrong 2020-01-14
Carlos 2020-01-08
明月清风精进不止 2020-01-01
tanrong 2019-12-13
明月清风精进不止 2019-10-23
zhangdonghang 2019-07-18
chenxcd 2019-09-06
sylalak 2014-08-30
FightFourEggs 2010-08-14
廖金龙 2013-03-20
wangcomputer00 2012-07-06
windex000 2018-10-15
libingjy 2016-10-05
MikeG 2015-07-26