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.
SELECT *
FROM [dbo].[Orders]
WHERE
DATEPART(m, CreatedOn) = DATEPART(m, DATEADD(m, -1, getdate())) AND
DATEPART(yyyy, CreatedOn) = DATEPART(yyyy, DATEADD(m, -1, getdate()))
0 comments:
Post a Comment