
September 19th, 2012, 11:17 AM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 2
Time spent in forums: 7 m 25 sec
Reputation Power: 0
|
|
Actually, just modified the first 'where' clause to this, and it works:
Code:
where Date 'TODAY' between Coalesce(DateStart, 'TODAY') and Coalesce(DateEnd, 'TODAY')
Quote: | Originally Posted by DwightM In the following example, only the last 'where' clause produces the required results. Shouldn't all three where clauses produce the same results (return both rows)?
Code:
select *
from (
select 1 as ID, Date 'Sep 18, 2012' as DateStart, Date 'Dec 18, 2012' as DateEnd from RDB$DATABASE
union select 2 as ID, cast(null as Date) as DateStart, Date 'Jan 18, 2013' as DateEnd from RDB$DATABASE
) as Test
--where 'TODAY' between Coalesce(DateStart, 'TODAY') and Coalesce(DateEnd, 'TODAY')
--where Coalesce(DateStart, 'TODAY') >= DateStart and Coalesce(DateEnd, 'TODAY') <= DateEnd
where (DateStart is null or 'TODAY' >= DateStart) and (DateEnd is null or 'TODAY' <= DateEnd)
|
|