Solved

simple DATEFORMAT query

Posted on 2008-06-14
4
287 Views
Last Modified: 2013-12-24
i need to get the all 12 months from my date (thisMonth) and output them to screen, thanks

<cfset thisMonth = #DATEFORMAT(now(), "dd/mm/yyyy")#>
0
Comment
Question by:pigmentarts
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21786657
which 12 months, actually?
can you clarify that, please?
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 21786730
1 months from the current date i have managed to do it like this... not sure if its the best way but works


<cfset thisMonth = #DATEFORMAT(now(), "mmmm/yyyy")#>



<cfscript>
thisMonth = #DATEFORMAT(now(), "mmmm/yyyy")#;
WriteOutput("#thisMonth#<br />");
// output the loop index in each iteration
for (idx = 1; idx lte 12; idx = idx +1) {
paMonths = #DateFormat(DateAdd('m', -#idx#, thisMonth),'mmmm/yyyy')#;
   WriteOutput("#paMonths#<br />");
}
</cfscript>
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 21788076
You can reduce that to this:

<cfscript>
thisMonth = now();
// output the loop index in each iteration
for (idx = 0; idx lte 12; idx = idx +1) {
   WriteOutput(DateFormat(DateAdd('m', -idx, thisMonth),'mmmm/yyyy') & "<br />");
}
</cfscript>


But what is the question?
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 21789486
thanks Zvonko
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question