I want to turn a short date in varchar into a date:
‘Short month name – YY’ format such as 'Apr-57'
or 'Mar-2001'
to an readable format for MSMS to turn it into a date such as 1957-04-01
or 2001-03-01
.
Is there a shortcut I am missing? I’ve tried to convert, cast, and substring to alter the format to see if it would help. Thank you for any help in advance.
Advertisement
Answer
Does this help?
DECLARE @vc VARCHAR(50) = 'Mar-2001'; SET @VC = '01-' + @vc; SELECT CAST(@VC AS DATE);