Solved

simple DATEFORMAT query

Posted on 2008-06-14
4
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

628 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