Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL script

I want to write below SQL script in Qlikview.

'FM' + right('0'+ convert(varchar,datepart(mm, DATEADD(MONTH, -3, Period))),2) + '-' + convert(varchar(3),datename(month, Period)) as Fin_Month

Can someone help me out please ?

Thanks

5 Replies
Not applicable
Author

'FM' & num(addmonths(Period,-3),'00') & text(month(Period))

should do it

Not applicable
Author

Hi  Dion,

I tried your solution but did not work in my case.

I’ve done like this in the qlikview.

'FM' & num(addmonths(Period,-3),'00') & text(month(Period)) as Fin_Month

But finally I ended up with the following values in the list box.

FM40909Apr, FM40940May… so on.

Actually, In the SQL server I got values like this: FM01-Apr, FM02-May….so on

Do you have any other solution ?

Thanks

Not applicable
Author

Hi,

I've made a mistake and forgot the month function.

'FM' & num(month(addmonths(Period,-3)),'00') & text(month(Period))


Try this.

MayilVahanan

Hi

Try like this

'FM' & num(month(addmonths(Period,-3)),'00') &'-' & text(month(Period))

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Perfectly working. Thank you very much Dion!