Magpie Magpie - 7 months ago 142
SQL Question

SmallDateTime Min and Max Values in C#

In C# there's a

, but I can't find one for the
datatype from SQL Server.

var smallDateTimeMin = DateTime(1900, 1, 1);
var smallDateTimeMax = DateTime(2079, 6, 6);

Is there one or do I need to implement this myself?


There is no smalldatetime equivalent in System.Data.SqlTypes. Nor is there an equivalent for the new datetime2 type. So I wouldn't expect min-max constants for those types in the .NET framework.

But the types are well documented on MSDN:

Date and time data from January 1, 1753 through December 31, 9999, to an accuracy of one three-hundredth of a second (equivalent to 3.33 milliseconds or 0.00333 seconds). Values are rounded to increments of .000, .003, or .007 seconds, as shown in the table.

So you can easily define your own min-max constants.