I have a table with a series of dates. What I want to do is take the very last date in the table and propagate the next 52 weeks. I don't have any clues as to how to do this. I know I'll need a loop structure to count 52 loops but where I'm lost is how to do the loop function.
My table is very simple:
ID (Autonum) | Datevalue (smalldatetime)
is loop count = 52?
repeat loop
repeat grabbing last entry until we cycle through 52 iterations (this is where I'm confused) so I need help with the loop, any ideas?
My table is very simple:
ID (Autonum) | Datevalue (smalldatetime)
is loop count = 52?
If yes quit
if no then begin loop
if no then begin loop
Code:
// Grab last Datevalue ID and then add 7 days to that date SELECT MAX 1 id, Datevalue AS newdateval from Table ORDER BY id desc newdateval = DateAdd(day,7,newdateval) // Insert the new date INSERT INTO Table ([Datevalue]) values ([newdateval])
repeat grabbing last entry until we cycle through 52 iterations (this is where I'm confused) so I need help with the loop, any ideas?
Comment