I need to select a date range from a MSSQL database but the s.ended field has not been set up as a datetime field. It has been set up as a varchar and the format for the date stored is d/m/Y.
I have tried the below were clause but I get the below error message. Does anyone know of how I can get round this without changing the database design?
Where clause:
WHERE
(S.ended > CONVERT(DateTime, '28/07/2012 00:00:01', 103))
AND (S.ended < CONVERT(DateTime, '28/08/2012 00:00:01', 103))
Error message:
The conversion of a varchar datatype to a datetime data type resulted in an out of range value.
Try this: