Tuesday, 20 March 2018

SQL Query to Get the records of last month in SQL server

SQL Query to Get the records of last month in SQL server

Description:


In this example we explain that how to get records of previous month using SQL Server. Or SQL Query to get the Last Month record in SQL Server. Or SQL Query to return all records from previous month using SQL Server. Or SQL query to select all records created in previous month. Or how to retrieve Last month date values in SQL Server.

So here we demonstrate that how to get records of the Last or Pervious month using SQL Server.
Query:

SELECT *
FROM [dbo].[Orders]
WHERE
DATEPART(m, CreatedOn) = DATEPART(m, DATEADD(m, -1, getdate())) AND DATEPART(yyyy, CreatedOn) = DATEPART(yyyy, DATEADD(m, -1, getdate()))


This entry was posted in :

0 comments:

Post a Comment