You are misusing the month()
function. From the docs:
Extracts the month value from a date/time object
You are passing in a number, which CF implicitly converts to a date (probably 01/03/1900), just not the correct one. So month()
is actually returning 1
. That is why your results say January 2013.
A simpler way to accomplish this is to use dateAdd
. Simply calculate the first of the current month. Then subtract months or days to get the start and end of the previous month. (Note: I would leave the values as date objects and only "format" them when you need to display them to the user).
<cfscript>
today = now();
firstOfThisMonth = CreateDate( year(today), month(today), 1);
firstOfLastMonth = dateAdd("m", -1, firstOfThisMonth);
endOfLastMonth = dateAdd("d", -1, firstOfThisMonth);
</cfscript>