Solved

simple DATEFORMAT query

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

Save on storage to protect fatherhood memories

You're the dad who has everything. This Father's Day, make sure your family memories are protected. My Passport Ultra has automatic backup and password protection to keep your cherished photos and videos safe. With up to 3TB, you have plenty of room to hold the adventures ahead.

Question has a verified solution.

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

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

911 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

19 Experts available now in Live!

Get 1:1 Help Now