Solved

simple DATEFORMAT query

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now