Wednesday, 28 February 2018

SQL Query to return all records from current month or This month

Get Current Month's data using sql query
Description:


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

-- Get This month Record
SELECT *
FROM [dbo].[Orders]
WHERE
MONTH([OrderDate]) = MONTH(dateadd(dd, -1, GetDate()))
AND
YEAR([OrderDate]) = YEAR(dateadd(dd, -1, GetDate()))



This entry was posted in :

0 comments:

Post a Comment