How to select data between the previous month and current month

Aug 4 2021 9:33 AM

Hi,

I am still very new to SQL. How to select data between the previous month and current month with SQL.

I know previous month is "WHERE DATEPART(m, datefieldname) = DATEPART(m, DATEADD(m, -1, getdate()))  AND DATEPART(yyyy, datefieldname) = DATEPART(yyyy, DATEADD(m, -1, getdate()))" and current month is " WHERE datepart(mm,DATEFIELDNAME) =month(getdate()) and datepart(yyyy,DATEFIELDNAME) =year(getdate())"

I just don't know how to join them to go and look in both these months. 

 

Regards

Monique


Answers (1)