原理是从master..spt_values表里面取出操作日期的数字,取生成后小于等于结束日期的日期
declare @starttime datetime; declare @endtime datetime; set @starttime='2020-08-01'; set @endtime='2020-08-05'; select dateadd(dd,number,@starttime) AS date from master..spt_values where type='p' and dateadd(dd,number,@starttime)<=@endtime;
最后结果是酱紫的~
date |
2020-08-01 00:00:00.000 |
2020-08-02 00:00:00.000 |
2020-08-03 00:00:00.000 |
2020-08-04 00:00:00.000 |
2020-08-05 00:00:00.000 |
微信扫码查看本文
发表评论