Using WHERE clause with BETWEEN and null date parameters

前端 未结 6 764

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:14

    Try this:

    WHERE ((DateCreated >= @DateFrom OR @DateFrom IS NULL) AND (DateCreated =< @DateTo OR @DateTo IS NULL))
    

提交回复
热议问题