To all,
I am trying to convert data in a varchar field to a datetime field in a temp table, so that I can perform MIN,MAX operations on the field.
I've tried CAST, CONVERT both without success:
SELECT DISTINCT strProviderID, CAST(StartDate AS datetime) AS StartDate
INTO ##BCR_05_temp2
FROM ##BCR_05_temp1
/*
Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.
*/
SELECT DISTINCT strProviderID, CONVERT(datetime,StartDate) AS StartDate
INTO ##BCR_05_temp2
FROM ##BCR_05_temp1
WHERE ##BCR_05_temp1.StartDate IS NOT NULL
/*
Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.
*/
The temp table ##BCR_05_temp1 has field values taken from a dbo.table whose StartDate field is a varchar.
Any ideas?
I'm kinda stumped on this one.
BTW: I got rid of any NULL values in the temp table & re-tried the operation with the same results.
Thanks!
Nick
I am trying to convert data in a varchar field to a datetime field in a temp table, so that I can perform MIN,MAX operations on the field.
I've tried CAST, CONVERT both without success:
SELECT DISTINCT strProviderID, CAST(StartDate AS datetime) AS StartDate
INTO ##BCR_05_temp2
FROM ##BCR_05_temp1
/*
Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.
*/
SELECT DISTINCT strProviderID, CONVERT(datetime,StartDate) AS StartDate
INTO ##BCR_05_temp2
FROM ##BCR_05_temp1
WHERE ##BCR_05_temp1.StartDate IS NOT NULL
/*
Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.
*/
The temp table ##BCR_05_temp1 has field values taken from a dbo.table whose StartDate field is a varchar.
Any ideas?
I'm kinda stumped on this one.
BTW: I got rid of any NULL values in the temp table & re-tried the operation with the same results.
Thanks!
Nick