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>
Lee R Liddick JrReporting AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

anandkpCommented:
try this :

<CFOUTPUT>
<CFSET PreviousMonth = Month(DateAdd('m',-1,Now()))>
<CFSET PreviousYear = Year(DateAdd('m',-1,Now()))>
<CFSET PreviousDays = DaysInMonth(DateAdd('m',-1,Now()))>

<CFSET StartDate = CreateDate(PreviousYear,PreviousMonth,1)>
<CFSET EndDate = CreateDate(PreviousYear,PreviousMonth,PreviousDays)>

#StartDate# - #EndDate#

</CFOUTPUT>


<CFQUERY name="sepempsmtd" datasource="myds">
     SELECT *
     FROM qsel_employee_info
     WHERE Active=0
          AND AWS_EndDate1 BETWEEN
              <CFQUERYPARAM CFSQLTYPE="CF_SQL_DATE" VALUE="#StartDate#">
              AND
              <CFQUERYPARAM CFSQLTYPE="CF_SQL_DATE" VALUE="#EndDate#">
     ORDER BY AWS_EndDate1 asc
</CFQUERY>
Similarly for the other query as well

K'Rgds
Anand
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lee R Liddick JrReporting AnalystAuthor Commented:
Perfect!  Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.