Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
kushalthakral
Creator III
Creator III

Get Previous Month from Today's date

Dear All

How i can get Previous month from Current date as i need to generate QVD and use Month and Year as their filed using system date.

Thanks

Kushal Thakral

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

Previous month

Month(AddMonths(Today(),-1))


Previous Year

Year(AddMonths(Today(),-1))


Current Month

Month(Today())


Current Year

Year(Today())

View solution in original post

13 Replies
MK_QSL
MVP
MVP

Month(Today())-1 as PreviousMonth

Update : The above will give you month number.

If you want month number, use below

in script

=Subfield('$(MonthNames)',';',Month(Today())-1) as PreviousMonth

in UI

=Subfield('$(MonthNames)',';',Month(Today())-1)

anbu1984
Master III
Master III

Month(AddMonths(Today(),-1))

its_anandrjs

Write like

Month(Max(DateField))-1 as PreviousMonth

What is mean for QVD generate and used Month Year

anbu1984
Master III
Master III

Manish,

If Month is January, Month(Today())-1 is zero and you will get nothing from this expression

Subfield('$(MonthNames)',';',Month(Date#('01/01/2014','D/M/YYYY'))-1)

MK_QSL
MVP
MVP

IF(Month(Date(YourDateField))-1=0,12,Month(Date(YourDateField))-1)

or

=Subfield('$(MonthNames)',';',IF(Month(Date(YourDateField))-1=0,12,Month(Date(YourDateField))-1))

kushalthakral
Creator III
Creator III
Author

Dear All

I dont have Date field so need to calculate Month and Year using system date

So can you help with the same.

Thanks

Kushal

MK_QSL
MVP
MVP

IF(Month(Today())-1=0,12,Month(Today())-1)

or

=Subfield('$(MonthNames)',';',IF(Month(Today())-1=0,12,Month(Today())-1))

anbu1984
Master III
Master III

Previous month

Month(AddMonths(Today(),-1))


Previous Year

Year(AddMonths(Today(),-1))


Current Month

Month(Today())


Current Year

Year(Today())

Not applicable

Hi Kushal,

You try the following Syntax-:

=SUM({<MONTH={">=$(=MIN(MONTH)-1)<=$(=MAX(MONTH)-1)"}>}FIELDNAME)

it definitely work.