Hi,
I have a T-SQL stored procedure where I want to search for a particular value and optionally limit the search to particular dates if they are passed in. If null values are passed in for either of these dates, then I want to ignore those. The way I am thinking of doing this by setting the input dates to minimum or maximum if they are null. I would prefer not to hardcode the minimum and maximum values though. So I am wondering what the SQL equivalent of the C# DateTime.MaxValue
and DateTime.MinValue
are.
I am thinking of using Coalesce like so
SELECT EmployeeName FROM Employee
WHERE EmployeeID = @EmployeeId AND
Birthday BETWEEN Coalesce(@StartDate, <MinDateTime>) AND
Coalesce(@EndDate, <MaxDateTime>)
Is there a built in function/constant/variable/enum I can use for the <MinDateTime>
and <MaxDateTime>
variables?
Any suggestions?