Question
Rolling twelve months
I have a report that should always output twelve months worth
of data based on the closed date.
So this is what I have. First, I define today date :
<cfset today = #dateformat(now(), "mm/dd/yyyy")#>
I then calculated one year ago, from today :
<cfset lastyear = #dateformat(datediff("d",365,today),"mm/dd/yyyy")#>
In my query, I have :
WHERE closedDate between #CreateODBCDate(lastYear)# and #CreateODBCDate(dateadd("d", 1, today))#
So everytime they run the report, it should give one year/tweleve months worth of data.
Is this the right way to do this, or is there a more efficient method ?
I tested and it seems to work, but my test data is very limited so I am not really sure if it is picking up the correct data or not.
So this is what I have. First, I define today date :
<cfset today = #dateformat(now(), "mm/dd/yyyy")#>
I then calculated one year ago, from today :
<cfset lastyear = #dateformat(datediff("d",365,today),"mm/dd/yyyy")#>
In my query, I have :
WHERE closedDate between #CreateODBCDate(lastYear)# and #CreateODBCDate(dateadd("d", 1, today))#
So everytime they run the report, it should give one year/tweleve months worth of data.
Is this the right way to do this, or is there a more efficient method ?
I tested and it seems to work, but my test data is very limited so I am not really sure if it is picking up the correct data or not.
