Sample Header Ad - 728x90

Help with out-of-range value

2 votes
1 answer
6529 views
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.
Asked by Docjay (25 rep)
Apr 24, 2014, 07:25 PM
Last activity: May 7, 2020, 06:40 PM