nDays := Round( dEndTime - dStartTime ) + 1;
For i in 1..7 Loop
nDay := i + 1;
if i = 7 Then
nDay := 1;
End If;
SELECT To_Date(To_Char((dStartTime+Level-1),'DD.MM.YYYY')||' 00:00','DD.MM.YYYY HH24:MI'),
To_Date(To_Char((dStartTime+Level-1),'DD.MM.YYYY')||' 23:59','DD.MM.YYYY HH24:MI')
FROM DUAL
WHERE To_Char( dStartTime + Level -1 , 'd' ) = To_Char(nDay)
CONNECT BY Level <= nDays;
End Loop;
输出:
22-JUL-12
23-JUL-12
18-JUL-12
19-JUL-12
20-JUL-12
21-JUL-12
我需要将此查询转换为 SQL Server 2008,请帮助找到相同的解决方法......
我已经用 nDay 从 1 到 7 的单个查询尝试了上述输出.....