Printing out Months and Years between two dates
I have two dates, example would be 10/1/2006 and the current date 9/8/2007. How would I loop through and print out every month between these two dates with the year?
October 2006
November 2006
December 2006
January 2007
etc...
September 2007
Any ideas? and thanks!
Re: Printing out Months and Years between two dates
try like this
vb Code:
For i = DateDiff("m", "10/1/2006", "9/8/2007") To 0 Step -1
Print Format(DateAdd("m", -i, "9/8/2007"), "mmmm yyyy")
Next
on my system it prints from january 2006 to august 2007, but that is because my locale date setting is dd/mm/yyyy, should work right on systems where locale date is mm/dd/yyyy
as there is no way to tell from 10/1/2006 which is the month (unless you know) there is no foolproof way to code it so that it will always be correct, if you use a date format like oct 1 2006 then it can always be correct, using now or date for the current month will always be correct