Hi,
I have a varchar field (DischargeDate) that I am using in a where clause. I firstly want to convert this to a DateTime datatype and then use the IsNull function on it.
The syntax I'm using is: -
SELECT *
FROM EpisodeE
WHERE Convert(DateTime,(IsNull(EpisodeE.DischargeDate,'')),101)
Between '2009-01-01 00:00:00' AND '2009-01-31 23:59:59'
but it is giving me the error: -
Error: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. (State:22008, Native Code: F2)
I'd appreciate any suggestions. Thank you!
I have a varchar field (DischargeDate) that I am using in a where clause. I firstly want to convert this to a DateTime datatype and then use the IsNull function on it.
The syntax I'm using is: -
SELECT *
FROM EpisodeE
WHERE Convert(DateTime,(IsNull(EpisodeE.DischargeDate,'')),101)
Between '2009-01-01 00:00:00' AND '2009-01-31 23:59:59'
but it is giving me the error: -
Error: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. (State:22008, Native Code: F2)
I'd appreciate any suggestions. Thank you!