Home > OS >  Convert a non-standard format string to a date
Convert a non-standard format string to a date

Time:10-05

In SQL Server, I queried a column called DelDate which contains all the date as character string like

"Thu 1/9/2022"
"Wed 12/9/2022"

It impossible to compare manipulate this column with other columns contain standard format dates. I tried to use the command like

Convert(DATE, DelDate)

but got the error message:

Conversion failed when converting date and/or time from character string.

Any suggestions?

Thanks

CodePudding user response:

I would do something like this:

SELECT CONVERT(Date, RIGHT('Wed 12/9/2022', LEN('Wed 12/9/2022') - 4), 103) DelDate2
  • Related