I want to validate a System.DateTime value before I add it as a parameter to my SqlCommand instance.
The MSDN documentation for the SqlDbType enumeration says:
Date and time data ranging in value from January 1, 1753 to December 31, 9999 to an accuracy of 3.33 milliseconds.
To validate the value, I'm using
public readonly DateTime SqlDateTimeMin = new DateTime(1753, 1, 1);
public readonly DateTime SqlDateTimeMax = new DateTime(9999, 12, 31);
if (value < SqlDateTimeMin || value > SqlDateTimeMax)
// Validation check fails
else
// Validation check succeeds
Is this the best way? Is there an alternative to hard coding these min and max values?