Query to get records between two dates in sql server 2008

InfoPath alternatives for form designing SharePoint
In this post we will discuss how we can retrieve records between two dates in sql server 2008. Also check out my previous posts on:
Retrieve a record from last 7 days:
Suppose you have an employee table and JoiningDate is a column and you want to retrieve who are the employees joined in last 7 days, then you can query like below:
select * from Employees WHERE JoiningDate BETWEEN GetDate()-7 AND GetDate()
Retrieve record between particular dates:
Below is the query to retrieve records between particular dates.
SELECT * FROM Employees WHERE CONVERT(VARCHAR,JoiningDate,105)
BETWEEN CONVERT(VARCHAR,’30-08-2013′,105) AND CONVERT(VARCHAR,’05-09-2013′,105)
Retrieve record for particular month and year:
Below is the query that will retrieve records for particular month and year.
The below query will retrieve record for the month of july and year of 2013:
SELECT * FROM Employees
   WHERE MONTH(JoiningDate) = 7 AND YEAR(JoiningDate) = 2013

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply