C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM ... . Ent


Posted Date: 05 Nov 2009      Posted By: Deshi      Member Level: Silver     Points: 1   Responses: 3



This strange error bugs me lot.... This is very strage, I'm trying to
insert data into the table through ADO.NET Entity Framework.. nothing
seems to work my way.. i've been getting error "SqlDateTime overflow.
Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM" .

here is my code
<code>
DirectoryEntities bdEntities = new DirectoryEntities();

Directory_SubCategory bdSubCatergories = new Directory_SubCategory();
Directory_Category categoryObject = new Directory_Category();
bdSubCatergories.Directory_Category = categoryObject;
bdSubCatergories.SubCategoryName = masterParams[0];
bdSubCatergories.Directory_Category.CategoryID = Convert.ToInt32
(masterParams[1]);
bdSubCatergories.CreatedBy = Convert.ToInt32(masterParams[2]);
bdSubCatergories.CreatedDate = DateTime.Now; ///This could be
source of error
bdSubCatergories.ModifiedDate = DateTime.Now;
bdEntities.AddToBusinessDirectory_SubCategory(bdSubCatergories);
bdEntities.SaveChanges(true); //It throws me exception here
</code>
All my previous database insertions are happening perfectly. in this
case i'm getting strange exception. reason could be i'm mapping two
table to update.. does anyone had this kind of error






Responses

Author: vipul    05 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Hi,
Please specify which date you enter then i say somthing.

Please Rate This Answer If They Helpful

Thanks & Regards
Patel Vipul



Author: Manick    06 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

I think there might be a datetime format mismatch while inserting. Please find the exact datetime format in the database and while inserting from the frontend, just convert the datetime according to your table.

Regards,
Manick



Author: Manick    06 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

You can also use this formats...

SELECT GETDATE() 'Date & Time',
CONVERT(VARCHAR,GETDATE(),103)'Date',
CONVERT(VARCHAR,GETDATE(),108) 'Time'

Date & time formats
====================
select CONVERT(VARCHAR,getdate(),101)
select CONVERT(VARCHAR,getdate(),102)
select CONVERT(VARCHAR,getdate(),103)
select CONVERT(VARCHAR,getdate(),104)
select CONVERT(VARCHAR,getdate(),105)
select CONVERT(VARCHAR,getdate(),106)
select CONVERT(VARCHAR,getdate(),107)
select CONVERT(VARCHAR,getdate(),108)
select CONVERT(VARCHAR,getdate(),109)
select CONVERT(VARCHAR,getdate(),110)
select CONVERT(VARCHAR,getdate(),111)
select CONVERT(VARCHAR,getdate(),112)
select CONVERT(VARCHAR,getdate(),113)
select CONVERT(VARCHAR,getdate(),114)

Regards,
Manick



Post Reply
You must Sign In to post a response.
Next : Selecting last record
Previous : Query Plz!!
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use