Need to reformat Quarterly Date in SQL Server: 2021-Q2 should be shown as “Q2 / 21”

juud5qan  于 2022-12-22  发布在  SQL Server
关注(0)|答案(1)|浏览(125)

Example: I have a column which have values in the format of 2021-Q2 .
How do I reformat those values to the format Q2/21 ?
I had tried substring .

oyjwcjzk

oyjwcjzk1#

declare @InString varchar(10)='2021-Q2'

select RIGHT(@InString,2)+'/'+RIGHT(LEFT(@InString,4),2);

相关问题