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;
output:
22-JUL-12
23-JUL-12
18-JUL-12
19-JUL-12
20-JUL-12
21-JUL-12
I need to convert this query to SQL Server 2008, please help to find workaround with the same......
I have tried above output with single query with nDay from 1 to 7.....