im trying to get a date from a name i have got the date but i need it to be in yyyy-mm-dd format.
what i get: 20221201
what i need: 2022-12-01
please help me on this
CodePudding user response:
Could be as simple as this ... assuming the date string is the last 8 characters
Example
Select try_convert(date,right('typographical_dismal_subjoinByapostrophize1_12345_20221201',8))
Resutls
2022-12-01
CodePudding user response:
This should work ,
SELECT CONVERT(DATE,RIGHT('ABCDEF20221201',8),103)