Solved

simple DATEFORMAT query

Posted on 2008-06-14
4
289 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 143

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
cookies analysis tools 2 100
coldfusion cfloop help 6 34
How to generate a JSON response in coldfusion 4 61
Adding multiple JVM environments to RedHat 6 7 49
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 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