Quite often I have to write queries to return rows where something happened on a specific day. But the values in the table could be anytime within that day.
Previous I would pass in a start date, end date to do this, but the query then needs 2 parameters and it looks a bit cumbersome.
I came across this method which I now employ. Don't know if this has much performance impact, but it certainly is quicker to code and takes less parameters from calling application.
Where
(
DateDiff(day, @ReportStartDate,TerminalSession.StartDate) = 0
--StartDate >= @ReportStartDate
--And
--EndDate >= @ReportEndDate
)
No comments:
Post a Comment