Use:
WHERE StrTime <= @EndTime
AND @StrTime <= ISNULL(EndTime,'29991231')
Instead of:
WHERE
( (StrTime >= @StrTime and StrTime <= @EndTime) -- stoppage started while the given time and finished while or after the given time
OR (EndTime > @StrTime and EndTime <= @EndTime) -- stoppage finished while the given time and started while or before the given time
OR (StrTime < @StrTime and EndTime > @EndTime) -- stoppage started before the given time and finished after the given time
OR (StrTime < @StrTime and EndTime IS NULL) -- stoppage started before the given time and still not finished
)
No comments:
Post a Comment