How to convert in MS SQL server 2005 from string to Datetime datatype
SELECT[customer_key] ,
[company_code],
[distributor_code] ,
[dist_center],
[cust_code_ref] ,
[customer_name],
[customer_code],
[status],
[changedby] ,
CASE WHEN [status_date] ='0001-01-01' THEN CONVERT(DATETIME,'0001-01-01',111) ELSE CONVERT(DATETIME,[status_date],111) END AS [status_date],
[status_time]
FROM [stagedw].[dbo].[customer_cross_reference_src] a
Giving error:
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.