I’m having some trouble with the CreateDate() function, it’s just erroring and I have no idea why!
I am running this query to get all of the dates from news stories so that I can create a news archive monthly.
<cfquery name="selectNews" datasource="#Request.dsn#">
SELECT Month(NewsDate) AS theCount
FROM news
GROUP BY Month(NewsDate)
</cfquery>
Then when I output it, I’m trying to output it in the following format
- Aug 2012
- Sept 2012
- Oct 2012
So I’m using the following code to try to output this list
<ul>
<cfloop query="selectNews">
<cfoutput>
<cfset theDay = DateFormat(Now(), 'dd')>
<cfset theMon = theCount>
<cfset theYear = DateFormat(Now(), 'yyyy')>
<li>#CreateDate(theYear, theMon, theDay)#</li>
</cfoutput>
</cfloop>
</ul>
It works fine for the first item, it will output Aug 2012, however it will then error, saying this
Error Occurred While Processing Request
MONTH
Which to me, at least, is useless!
This was me being an idiot. I was using
DateFormat(Now(), 'dd'), which is a huge stupid mistake, seeing as there is only 30 days in September. It was runningCreateDate(2012, 09, 31), which obviously won’t work!