Friday, March 26, 2010

Adding a value to a 'datetime' column caused overflow.

Adding a value to a 'datetime' column caused overflow.

Came across this error today. So thought of posting the same.
Whenever you try to do a dateadd like this 

dateadd(mm,12,datefield)

you might face this error if the value in your records in the datefield is not a valid date or
if u add some months or date to this value and the output of that will exceed the date range

In my case i was just thinking what would be the error here.
But unfortunately there was some data in the table which was there with the value
(Ex:date of joining column)

1-1-9999

So my sql statement has tried to add 12 months to this and it had caused this error.

2 comments:

  1. is there any other way to get rid of this??
    Did you got any other solution in order to use DateAdd function??

    Thanks !

    ReplyDelete
  2. no you have to fix up the value in the table for the same..

    ReplyDelete