Using WHERE clause with BETWEEN and null date parameters

前端 未结 6 813

One of my WHERE clauses is the following:

AND (DateCreated BETWEEN @DateFrom and @DateTo OR (@DateFrom IS NULL OR @DateTo IS NULL))
6条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-04 01:22

    AND (DateCreated BETWEEN @DateFrom and @DateTo OR (ISNULL(@DateFrom, '')='' OR ISNULL(@DateTo, '')=''))
    

提交回复
热议问题