Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Last Three Months

Hi,

I'm trying to get the Month names for last three months.

I can get the current month name using the following expression:

Month(Today())

it returns me Nov.

But when I try using Month(Today())-1 it returns the value 10 instead of Oct.

To solve this issue I tried using Monthname(month(Today())-1) but it returns the value 'Jan 1900' instead of converting the '10' in Oct.

How can I get the previous month name?

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try Addmonths Function.

     =Month(Addmonths(Today(),-1))

          To get Previous Month.

     =Month(Addmonths(Today(),-2)) - to get the Month of Previous to Previous Month.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

4 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try Addmonths Function.

     =Month(Addmonths(Today(),-1))

          To get Previous Month.

     =Month(Addmonths(Today(),-2)) - to get the Month of Previous to Previous Month.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

 

Month(AddMonths(today(),-1))

U can use it to return previous month...

Not applicable
Author

Thanks. It worked

Not applicable
Author

The Kaushik Solanki response is correct to get the previous months. Then you can use the Date function to format that dates as desired:

=Date(AddMonths(Today(), -1), 'M') --> 10

=Date(AddMonths(Today(), -1), 'MMM') --> oct

=Date(AddMonths(Today(), -1), 'MMMM') --> october