Challenge:
One of my colleague was writing a query to get records between start date and enddate.
SELECT EmployeeName From Employees WHERE EmployeeJoiningDate >= @startDate AND EmployeeJoiningDate<=@endDate
it was working fine but some records are not showing up in the list because it was checking time also. Which he don’t want to compare..So, how to get just date part and compare it with provided params?
Solution:
We found the way for it using
SELECT CONVERT(VARCHAR(10),GETDATE(),101) --101 = mm/dd/yyyy
it made his work simple!!. So, just convert your date and then compare..for brevity i left up to you to write a new sql statement
Here 101 is one of the style to get date. for list of style go to MSDN
Happy Programming!