SQL 2000 -
I have three date fields, "Start", "Target", "Completed".
I need to let the user choose a value for each, or leave it blank.
The start date is required. All projects have a start date (relates to a creation date) The target can be TBD, which is null, and Completed can be blank, because it's not done yet.
IF the user enters a Completed date, then I want to return:
But if they leave it blank, then I want to return ALL rows, I.E. no WHERE expression. Same with target.
I am thinking a user defined function, along the lines of
Would return true or false, and I can determine the criteria through a simple IF statement in code.
My question is this:
Is there a way to do this all inside the stored proc, without adding another object to the database?
Kevin
I have three date fields, "Start", "Target", "Completed".
I need to let the user choose a value for each, or leave it blank.
The start date is required. All projects have a start date (relates to a creation date) The target can be TBD, which is null, and Completed can be blank, because it's not done yet.
IF the user enters a Completed date, then I want to return:
Code:
WHERE Completed < @Completed
I am thinking a user defined function, along the lines of
Code:
WHERE fTestDate(Completed, @Completed) AND fTestDate(Target, @Target)
My question is this:
Is there a way to do this all inside the stored proc, without adding another object to the database?
Kevin