Below are listed two code snippets from a recent project I have been working on. What I am trying to do is compare two dates and return all of the results that fall on or between the two dates. The first code snippet will return the starting date that I input and every day up to, but NOT including, the end date I input.
The second snippet returns all of the data I want INCLUDING data from the end date I input. I have tried using <=. This will not error out but it still returns incorrect data in the same way the first code snippet does.
My question is , is this by design? In other words is the second code snippet the correct way to compare dates or am I missing something that could make this process easier.
Any help is appreciated.
(Code that does not work)
where (modifieddate >@begindate and modifieddate<@enddate)
(Code that does work)
where (modifieddate >@begindate and dateadd(day,-1,modifieddate) <@enddate)