I have a data result that I want to filter by two different dates.
The below is working except when completion_date is null. If it is null I want to use a different field called created_date.
string strSQL = string.Format(@"select * from my_table
where user_Id = {0}
AND [completion_date] between {1} AND {2}
order by completion_status desc, [completion_date] asc"
, userId, dateStart, dateEnd, visibilityIndicator);
Perhaps something like this:
string strSQL = string.Format(@"select * from my_table
where user_Id = {0}
CASE completion_date
WHEN is null THEN [completion_date] between {1} AND {2}
ELSE [created_date] between {1} AND {2}
END
AND
order by completion_status desc, [completion_date] asc"
, userId, dateStart, dateEnd, visibilityIndicator);
What is the best way to check for that null value and then switch to created_date?
should work