I have this query that runs fine:
SELECT
Value
FROM data
WHERE MetaDataID = 'f249819e-817f-4be5-bee9-21aa3d7f72e6'
which returns:
27/6/2011 19:12:28
11/7/2011 19:18:54
10/7/2011 11:49:35
3/7/2011 17:41:53
if I Alter the query to:
SELECT
VALUE,
MONTH(Value)
FROM data
WHERE MetaDataID = 'f249819e-817f-4be5-bee9-21aa3d7f72e6'
I get the error: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
Info that might help:
1) The Value Column is VARCHAR type.
2) WHEN I specify the MetaDataId, I make sure the result is “date”. to make sure, I’ve used WHERE IsDate(Value) = 1 too and also I’ve used ISDATe(Value) on the select to see if every result was a date and it was…
I don’t known why this is hapenning… Anybody have a clue?
You have to perform an explicit conversion to a
datetimedatatype.