Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL script


Hi,

I have the below sql code.

'F' + right(convert(varchar,datepart(mm, DATEADD(MONTH, -3, Period))),2) + '-' + convert(varchar(3),datename(month, Period)) as FinMonth

which is giving results like

F1-Apr, F2-May.....F12 March.

Is there any way that I can add "year" as well ?... just like F1-Apr13, F2-May13......F12Mar12.

Thanks

2 Replies
greg-anderson
Luminary Alumni
Luminary Alumni

'F' + right(convert(varchar,datepart(mm, DATEADD(MONTH, -3, Period))),2) + '-' + convert(varchar(3),datename(month, Period)) + right(text(year(Period))) as FinMonth

Not applicable
Author


Thanks for your reply Greg. Right(text(year(period))) is not working. I tried with right(datepart(year,Period),2) and it is working fine. Thanks anyway!