Maybe this can't be done (other than with executing a SQL string) and I have tried many different ways but basically I want to build a dynamic where clause with both sides of the conditions as variables.
I need something like (but that works):
WHERE 0 = 0
AND (
(CASE @dateCondition
WHEN 'DateCreated' THEN DateCreated
WHEN 'DueDate' THEN DateCreated
WHEN 'CompletionDate' THEN DateCreated
END) = @dateFrom)
OR essentially
WHERE @dateCondition = @dateFrom