Help with out-of-range value
-
02-11-2019 - |
题
I have this query that is giving me an error
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Query:
select
COUNT(*)
from
dbo.patient
INNER JOIN
dbo.study on dbo.patient.pk = dbo.study.patient_fk
and dbo.study.study_datetime IS NOT NULL
and dbo.patient.pat_birthdate IS NOT NULL
and dbo.study.study_datetime <= DATEADD(D, -2192, GETDATE())
and dbo.patient.pat_birthdate <= DATEADD(D, -7670, GETDATE());
I read where this might help to be converted to 'DATETIME2', but I can't quite figure out how to correctly convert the column 's.study_datetime' as this column more than likely has some bad values as entries.
没有正确的解决方案
不隶属于 dba.stackexchange