-
February 10th, 2009, 11:55 AM
#1
datetime C# equvalent
I have the following table column
Code:
[hire_date] [datetime] NOT NULL DEFAULT (getdate()),
Then using Linq I try the following
employee e1 = new employee
{
.....
hire_date = new DateTime()
};
And I get this error:
Code:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
What is the C# equivalent for MSSQL datatime database type ?
-
February 10th, 2009, 12:15 PM
#2
Re: datetime C# equvalent
I don't think there is one. I normally set a static global variable to the "1753" date and just use that when instantiating dates.
-
February 10th, 2009, 12:21 PM
#3
Re: datetime C# equvalent
Originally Posted by eclipsed4utoo
I don't think there is one. I normally set a static global variable to the "1753" date and just use that when instantiating dates.
like this
new Datetime("1973") ?
-
February 10th, 2009, 01:34 PM
#4
Re: datetime C# equvalent
no, like
Code:
Convert.ToDateTime("1/1/1753 12:00:00 AM");
-
February 10th, 2009, 03:07 PM
#5
Re: datetime C# equvalent
-
February 14th, 2009, 05:17 PM
#6
Re: datetime C# equvalent
DateTime maps to SQL's datetime, but the valid range is different. To initialize a DateTime with the minimum value use:
System.Data.SqlTypes.SqlDateTime.MinValue.Value
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|