John,

Re-reading your post I realized my solution was all wrong, it's
definitely Monday around here...

Just use the dateAdd() , adding a month each time, until you get where
you need to go.  It'll handle the year etc. for you.

-joe

----- Original Message -----
From: John Beynon <[EMAIL PROTECTED]>
Date: Mon, 9 Aug 2004 15:23:18 +0100
Subject: Re: looping over dates?
To: CF-Talk <[EMAIL PROTECTED]>

i just got to:

<cfset startmonth="4">
<cfset startyear="2003">

<cfloop from="#startyear#" to="#dateformat(now(),"yyyy")#" index="y">

<cfif dateformat(now(),"yyyy") eq y>
<cfset endmonth = dateformat(now(),"mm")>
<cfelse>
<cfset endmonth = 12>
</cfif>

<cfloop from="#startmonth#" to="#endmonth#" index="i">
#dateformat('#i#/1/#y#',"mmmm yyyy")#<br />
</cfloop>

<cfset startmonth = 1>

</cfloop>

which is pretty similar to what's being suggested. I'll use a mixture
of all - thanks all!

jb.

On Mon, 9 Aug 2004 15:26:22 +0100, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> >> I want to programmatically create a consecutive list of months/dates
> >> starting from a certain month, eg
>  
> Set your intial date, set your max date, loop round incrementing the
> month by one using dateAdd
>
> <cfscript>
>    startDate = createDate(2003, 03, 01);
>    endDate = now();
>    thisDate = startDate;
>
>     while (dateCompare(thisDate, endDate, "m") lt 1) {
>         writeoutput(MonthAsString(Month(thisDate)) & " " &
> Year(thisDate) & "<br />");
>         thisDate = dateAdd("m", 1, thisDate); //Increment month
>     }
> </cfscript>
>
>
>________________________________
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to