Fred
asked on
How can I convert a column that is varchar(50) to Date time
I want to convert a table column to DATETIME, I used alter table name [Dim_Loan] alter column LoanDate datetime, got an error, Conversion failed when converting date and/or time from character string . The column LoanDate is varchar(13), LoanDate column has this output Jan 11 2020 1, am not sure what the 1 stands for. The Loan Date is being used in a store procedure as a Report Date with datetime as its data type
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Not sure what happened earlier but now it works, I had scrolled down the table and notice some rows had the 1 so I updated the whole table again,
2020-01-14 is the new data type,
2020-01-14 is the new data type,
ASKER
the first update went halfway down the table am not sure why, but I scrolled down the table and noticed some rows still had the 1, I updated the table and was able to convert the Loan Date column to date, am curious what this means '[A-Z][a-z][a-z] [0-9]%[2][0-9][0-9][0-9]%'
What the pattern means is the characters must be:
letter
letter
letter
space
number
<any number of any type of chars> [to allow for Jan 1 yyyy and Jan 11 yyyy, just in case a single-digit day is allowed]
'2'
number
number
number
<any number of any type of chars>
ASKER