Lee R Liddick Jr
asked on
Previous Month Results in Query
I need to create a query that is going to give me a list of last month results. I know how to get the mtd results, but how do I get last months? In my previous mtd query, it is giving me last month results but it is also including the first day of the current month...but I only want results for the month of September only.
QUERY INFORMATION:
<cfset TodayDate = DateFormat(Now(), "M/D/YYYY")>
<cfset FirstOfMonth = Month(Now()) & "/1/" & Year(Now())>
<cfset FirstOfLastMonth = Month(Now())-1 & "/1/" & Year(Now())>
<CFQUERY name="sepempsmtd" datasource="myds">
SELECT *
FROM qsel_employee_info
WHERE Active=0
AND AWS_EndDate1 BETWEEN ###FirstOfMonth### AND ###TodayDate###
ORDER BY AWS_EndDate1 asc
</CFQUERY>
<CFQUERY name="sepempsprevmtd" datasource="myds">
SELECT *
FROM qsel_employee_info
WHERE Active=0
AND AWS_EndDate1 BETWEEN ###FirstOfLastMonth### AND ###FirstOfMonth###
ORDER BY AWS_EndDate1 asc
</CFQUERY>
QUERY INFORMATION:
<cfset TodayDate = DateFormat(Now(), "M/D/YYYY")>
<cfset FirstOfMonth = Month(Now()) & "/1/" & Year(Now())>
<cfset FirstOfLastMonth = Month(Now())-1 & "/1/" & Year(Now())>
<CFQUERY name="sepempsmtd" datasource="myds">
SELECT *
FROM qsel_employee_info
WHERE Active=0
AND AWS_EndDate1 BETWEEN ###FirstOfMonth### AND ###TodayDate###
ORDER BY AWS_EndDate1 asc
</CFQUERY>
<CFQUERY name="sepempsprevmtd" datasource="myds">
SELECT *
FROM qsel_employee_info
WHERE Active=0
AND AWS_EndDate1 BETWEEN ###FirstOfLastMonth### AND ###FirstOfMonth###
ORDER BY AWS_EndDate1 asc
</CFQUERY>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER