• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 181
  • Last Modified:

12 Month increment

Hello,

If I wanted to display the next 12 months in rows (<td></td>). How would I do this with Coldfusion?

So If this month was july I wanted to display this month and the next 11 months and year how would attempt to do this? Of course I would like the months and year to be separated into <td></td>'s as well.

Thank you,

Brian
0
brihol44
Asked:
brihol44
  • 2
1 Solution
 
gdemariaCommented:

<!---- assign theDate to be the first date of the current month --->
<cfset variables.theDate = createDate(month(now()),1,year(now())>  

<cfloop index="kk" from="1" to="12">  <!---- show 12 months --->
   <td>#dateFormat(DateAdd("m",kk-1,variables.theDate),"mmm-yy")#</td>
</cfloop>

0
 
brihol44Author Commented:
Thank you for responding however I get an error. I've been trying everything I can think of but something is not quite right. Thank you!

Brian

 Invalid CFML construct found on line 17 at column 65.
ColdFusion was looking at the following text:

>

The CFML compiler was processing:

    * an expression beginning with "createDate", on line 17, column 28.This message is usually caused by a problem in the expressions structure.
    * a cfset tag beginning on line 17, column 2.
0
 
gdemariaCommented:

 The error was caused by a missing ending )
    createDate(month(now()),1,year(now())>  
                                                                 ^^ ) needed


 But sorry, looks like I remember createDate() wrong.  Here's the correct order of the parameters.

<cfset variables.theDate = createDate(year(now()), month(now()), 1)>  

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now