SQL Query to find date between two datetime fields
Posted on 2013-12-09
I have a webform with a gridview. The gridview loads based on a date that equals the visitDate field or the endVisitDate field or a date between the two.
I have the part that selects the date equal to the visitDate or equal to the endVisitDate but I'm getting stuck on how to pull the date from between the two.
This is the query that works:
"SELECT visitorKey, visitorName1, visitorName2, visitDate, visitEndDate
FROM dbo.VisitorLog WHERE (DATEDIFF(d, visitDate, GETDATE()) = 0) OR (DATEDIFF(d, visitEndDate, GETDATE()) = 0) "
How do I do the third part selecting between the two dates?
Any help would be appreciated