Question

SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.

Hi All, 

 

Greetings!

Attaching my source code file.

 

UsrDate -> Date 

UsrStartTime -> Time

CreatedOn -> Date/Time

 

I am getting following error in few records - 

Worklogs Integrations synchronized with errors: {"bd455ee2-8f6e-4aed-bafc-890304110ac3":"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.","3d4508d8-bf40-48b4-ab65-d836c7c0b3da":"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM."}

screenshot from the source code is below - 


Screenshot of the record is below - 

 

 

Is it because Start time is NULL ?

If yes how can I handle this in the code so that the records gets synchronized with NULL ?


 

Thanks.

File attachments
Like 0

Like

1 comments

Hello.

I tried to do replicate the same situation. Activity table has a column SendDate which might be null. In business process i created a script task with the following code: 1

The result i got:
1
The values of SendDate columns in my Activity table were all null. All these values became the min value of datetime (1/1/0001 12:00:00 AM).

Your error message says that the datetime type in SQL Server has a limited range for dates it can store, specifically from January 1, 1753, to December 31, 9999. In .NET, the default value for DateTime is DateTime.MinValue, which is January 1, 0001. This default value is far outside the valid range for SQL Server's DateTime type.

After analyzing source code you provided i suggest taking a look at those lines of code and changing your sql command parameter types to SqlDbType.DateTime2:

insertCommand.Parameters.AddWithValue("@usrDate"...
insertCommand.Parameters.AddWithValue("@usrStartTime"...
insertCommand.Parameters.AddWithValue("@createdOn"...

Hope this helps

Show all comments