We help IT Professionals succeed at work.

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

running32
running32 asked
on
1,256 Views
Last Modified: 2012-06-22
i am getting the error "Adding a value to a 'datetime' column caused overflow."   when I try and run this statement.  DATEADD(dd, - 365, p.LASTMISSEDAPPT) < pl.PLDATE.  how can I change DATEADD(dd, - 365, p.LASTMISSEDAPPT) to avoid this.

Thanks
Comment
Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
what are values in the 2 fields? you might hit min value of date ...what about:
 p.LASTMISSEDAPPT < dateadd(dd, 365, pl.PLDATE)


resp:

p.LASTMISSEDAPPT < dateadd(year, 1, pl.PLDATE)

Open in new window

Commented:
Waht type is p.LASTMISSEDAPPT?

If p.LASTMISSEDAPPT is a float "representing" a date, then this value is likely
to be too high. If it exceeds 2936549 you will get an out or range error
(or similar error). If it represents a date, you should cast it to a
datetime.

Author

Commented:
Example of a field is the value of the fields could be 9/7/2010.  It still does it when I cast the value as datetime 101.  thanks

Commented:
have you tried this?

DATEADD(year, -1, p.LASTMISSEDAPPT)

Author

Commented:
yes, still gives me the same error.  Thanks

Commented:
There are any rows in your data table with this value in that field?

'1900-01-01 00:00:00'

Author

Commented:
NO the default date looks like 3/2/1753 or NULL
Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
You might look for this to find the problem data:

Select * from yourtable
  Where IsDate(p.LASTMISSEDAPPT) = 0

Commented:
maybe the minimum SQL DateTime Value is 1/1/1753. Substruct one year to fields with the value you have mentioned ("3/2/1753") throw the exception

Author

Commented:
angelIII, I tried your suggestion but it didn't work still gave the error

Server: Msg 517, Level 16, State 1, Line 1
Adding a value to a 'datetime' column caused overflow.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.