Datediff

05/09/2024 20:20 pardilias#1
Hi ,
here is my problem
Microsoft SQL server 2008 R2


PHP Fatal error: Uncaught PDOException: SQLSTATE[22003]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The datediff function resulted in an overflow. The number of dateparts separating two date/time instances is too large. Try to use datediff with a less precise datepart.


Thanks for your help
05/14/2024 15:17 512nil#2
This error occurs because the DATEDIFF function in SQL Server is attempting to calculate the difference between two dates with a very high precision, which results in an overflow. The solution is to use a less precise datepart to calculate the difference between the dates.

For example, if you are trying to calculate the difference between two dates in years, months, or days, you can use YEAR, MONTH, or DAY as dateparts, respectively. This will reduce the precision of the difference and avoid the overflow.