Zkuste toto -
SELECT foo,
bar,
test
FROM [table]
WHERE bar = 1
AND (
(
foo = 0
AND
DATEDIFF(dd, GETDATE(), 2 ) < test
)
OR
DATEDIFF(hh, GETDATE(), 2 ) < test
)