如果我有 2 天2013-06-03
,2013-06-10
例如,我如何打印这两个日期之间所有日期的列表?
例如,这种情况下的列表将是:
2013-06-22
2013-06-23
2013-06-24
2013-06-25
2013-06-26
2013-06-27
2013-06-28
2013-06-29
2013-06-30
2013-07-01
2013-07-02
2013-07-03
2013-07-04
2013-07-05
2013-07-06
2013-07-07
如果我有 2 天2013-06-03
,2013-06-10
例如,我如何打印这两个日期之间所有日期的列表?
例如,这种情况下的列表将是:
2013-06-22
2013-06-23
2013-06-24
2013-06-25
2013-06-26
2013-06-27
2013-06-28
2013-06-29
2013-06-30
2013-07-01
2013-07-02
2013-07-03
2013-07-04
2013-07-05
2013-07-06
2013-07-07
DECLARE @Start date = '2013-06-03'
DECLARE @End date = '2013-06-10'
;WITH Dates AS
(
SELECT @Start AS [Date]
UNION ALL
SELECT DATEADD(DAY, 1, [Date])
FROM Dates
WHERE [Date] < @End
)
SELECT [Date]
FROM Dates
OPTION (MAXRECURSION 0)
我想你正在寻找这个:
SELECT * FROM TABLE_NAME WHERE DATE_COLUMN_NAME BETWEEN '03-JUNE-2013' 和 '10-JUNE-2013'