user20152482
user20152482

Reputation:

need to get date from a name in sql server

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

Upvotes: 0

Views: 46

Answers (2)

KALYAN  KONDAPURAM
KALYAN KONDAPURAM

Reputation: 9

This should work ,

SELECT CONVERT(DATE,RIGHT('ABCDEF20221201',8),103)

Upvotes: 0

John Cappelletti
John Cappelletti

Reputation: 81970

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

Upvotes: 1

Related Questions