Hi,
I'm trying to extract records for this month and output the count as a figure. I also want to do this for last month. Obviously this will be dynamic so the months update themselves with the system clock.
I have written the code below but it doesn't seem to pull the correct records from my db - I only have records in there for August (Short Date dd/mm/yyyy) but it shows the same figure for Sept & Aug.
Can anyone help?
-
<cftransaction>
-
<cfset ThisMonth = Month(Now())>
-
<cfset LastMonth = Month(Now())-1>
-
<cfset ThisYear = Year(Now())>
-
<cfset DIM = DaysInMonth(Now())>
-
<cfset TMDate = '01/#ThisMonth#/#ThisYear#'>
-
<cfset LMDate = '#DIM#/#LastMonth#/#ThisYear#'>
-
</cftransaction>
-
-
-
<!--- Start of Colfusion block. Builds list data --->
-
<cftransaction>
-
-
<cfquery datasource="wflow" name="GetWIRecTM">
-
select *
-
from tblRecords
-
where DateRecordAdded Between #CreateODBCDate("#TMDate#")# AND #createODBCDate("#LMDate#")#
-
-
-
</cfquery>
-
-
-
<cfquery datasource="wflow" name="GetWIRecLM">
-
select *
-
from tblRecords
-
where DateRecordAdded BETWEEN #CreateODBCDate("01/#LastMonth#/#ThisYear#")# AND #CreateODBCDate("#DIM#/#LastMonth#/#ThisYear#")#
Thanks
Neil