PDA

View Full Version : looping thru months


dominicall
08-14-2003, 06:43 PM
OK - dumb question... but am a bit brain dead today...

I need to loop through months - which is no problem if the start month is 2 (Feb) and end month is 8 (Aug).

Am having trouble getting my head round looping thru months when start month is 9 (Sept) and end month is 3 (Mar).

Anyone got a nice solution.

Thanks

dominicall

raf
08-16-2003, 08:43 PM
I'm not sure i understand it. Do you want to print the month-names or something?
Or do you need a sort of ofset moth and then the six next months.

I don't exactly see the problem. Do you use DateAdd() ?

Like

dim newdate, interval, i
interval = 6 'but this could be a value the user posted or so
i=2
response.write(Monthname(Month(Now)) & "<br />")
do while i <= (interval - 1)
newdate = DateAdd("m",i,Now)
response.write(Monthname(Month(newdate)) & "<br />")
i = i + 1
loop