Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

$
0
0

I have the below query that works fine in non prod env while it throws above error in prod

      filecreationdate has VARCHAR(100) datatype and the sample value in the table is 'Dec 19 2013 12:00AM'

 SELECT 
CASE WHEN MSP.filecreationdate NOT LIKE '%T%' THEN CONVERT(INT,CONVERT(VARCHAR,CONVERT(datetime,MSP.filecreationdate),112))
            ELSE CONVERT(INT,CONVERT(VARCHAR,CONVERT(datetime,substring(MSP.filecreationdate,1,10)),112)) END
            FROM STAGING.dbo.cobenrollxmlMSP MSP



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>