如何在SQL中显示两个给定日期之间的所有日期
使用SQL Server2000.如果开始日期为06/23/2008
,结束日期为06/30/2008
Using SQL server 2000. If the Start date is 06/23/2008
and End date is 06/30/2008
然后我需要查询的输出为
Then I need the Output of query as
06/23/2008
06/24/2008
06/25/2008
.
.
.
06/30/2008
我创建了一个名为Integer的表,该表具有1列,列值为0、1、2、3、4、5、6、7、8、9,然后我使用了下面提到的查询
I Created a Table names as Integer which has 1 Column, column values are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 then I used the below mentioned query
尝试查询
SELECT DATEADD(d, H.i * 100 + T .i * 10 + U.i, '" & dtpfrom.Value & "') AS Dates
FROM integers H
CROSS JOIN integers T
CROSS JOIN integers U
order by dates
以上查询仅显示999个日期. 999个日期仅表示(365 + 365 + 269)个日期.假设我要选择3年以上(从2003年1月1日到2008年1月1日).上面的查询不适合.
The above query is displaying 999 Dates only. 999 Dates means (365 + 365 + 269) Dates Only. Suppose I want to select more than 3 Years (01/01/2003 to 01/01/2008). The above query should not suitable.
如何修改我的查询?或任何其他查询可用于上述条件.
How to modify my query? Or any other query is available for the above condition.
请向我提供查询.
这将使您长达100,000天:
This will get you up to 100,000 days:
SELECT DATEADD(d, Y.i * 10000 + X.i * 1000 + H.i * 100 + T .i * 10 + U.i, '" & dtpfrom.Value & "') AS Dates
FROM integers H
CROSS JOIN integers T
CROSS JOIN integers U
CROSS JOIN integers X
CROSS JOIN integers Y
order by dates