Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Month list between 2 dates!

Status
Not open for further replies.

micjohnson

Programmer
Nov 9, 2000
86
0
0
US
Can anyone please let me know to how to get the list of months as string between 2 dates.

Eg. From: 10/24/2002 To: 04/03/2003
==

List of months between these dates are October, Novermber, December, january, Feb, March, April.

Any functions or ideas to achieve this?

Thanks in advance.




 
Not sure is this the easier and shortest way. And you may need to run the script to check for errors. :>
<Cfoutput>
<Cfset numMonths = DateDiff(&quot;m&quot;, date1, date2)
<cfloop index=&quot;a&quot; from = &quot;1&quot; to =&quot;#numMonths#&quot;>
#monthasstring(DateAdd(&quot;m&quot;, 1, date1))#<br>
</cfloop>
</CFOUTPUT>
 
Just a slight mod to dragon's code...

<CFSET date1 = &quot;01 Jan 2000&quot;>
<CFSET date2 = &quot;01 Jan 2001&quot;>


<Cfoutput>
<Cfset numMonths = DateDiff(&quot;m&quot;, date1, date2)>
<cfloop index=&quot;a&quot; from = &quot;1&quot; to =&quot;#numMonths#&quot;>
#monthasstring(DatePart(&quot;m&quot;, DateAdd(&quot;m&quot;, a, date1)))#<br>
</cfloop>
</CFOUTPUT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top