Solved

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

Posted on 2010-09-09
11
1,097 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
0
Comment
Question by:running32
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33637608
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

0
 
LVL 3

Expert Comment

by:aledev
ID: 33637624
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.
0
 

Author Comment

by:running32
ID: 33637881
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
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 3

Expert Comment

by:aledev
ID: 33638035
have you tried this?

DATEADD(year, -1, p.LASTMISSEDAPPT)
0
 

Author Comment

by:running32
ID: 33638261
yes, still gives me the same error.  Thanks
0
 
LVL 3

Expert Comment

by:aledev
ID: 33638371
There are any rows in your data table with this value in that field?

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

Author Comment

by:running32
ID: 33638549
NO the default date looks like 3/2/1753 or NULL
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 33638579
which is the minimum year value (1753);
http://msdn.microsoft.com/en-us/library/ms187819.aspx

going 1 year back will indeed result in that error.
please try what I suggested first, changing to do the "dateadd(year,1 ,... )"
0
 
LVL 21

Expert Comment

by:mastoo
ID: 33638593
You might look for this to find the problem data:

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

Expert Comment

by:aledev
ID: 33638643
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
0
 

Author Comment

by:running32
ID: 33640011
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.

0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Slow Connectivity over ODBC 8 35
TSQL - How to declare table name 26 30
SQL Count issue 24 16
SQL Select to Group and Filter Data 5 12
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question