xiaocen 2008-08-21
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