@TimeCurr Char(1)
SELECT RecordDate, a, b,c
FROM tbl_xyz
WHERE 1 = 1
AND
if @TimeCurr = 'Y' Then RecordDate = GetDate()
if @TimeCurr = 'N' then RecordDate <= GetDate()
if @TimeCurr = Null then omit the critera altogether. How can we accomplish this?
Something like this:
Based on the use of
GETDATE(), I am guessing that you are using SQL Server. If so, the functionGETDATE()returns a date/time value. You don't usually want to use=with it. That is why I convert it to a date, assuming thatRecordDateis actually a date with no time component.