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

Last year same month variables

Hi,

We are having the below variables

let vMonthstart = date(MonthStart(today()-1),'1YYMMDD'); = 1161001

Let VLastMonthStart= date(monthStart(AddYears((today()-1),-1)),'1YYMMDD') ;=1150101

Here we required an variable which will give same month of last year like ,

VLastMonthStart = 1151001


Thanks..

1 Solution

Accepted Solutions
t_moutault
Contributor III
Contributor III

Hi,

Let VLastMonthStart= date(monthStart(AddYears((today()-1),-1)),'1YYMMDD') ;

works fine, give me 1151001

View solution in original post

3 Replies
t_moutault
Contributor III
Contributor III

Hi,

Let VLastMonthStart= date(monthStart(AddYears((today()-1),-1)),'1YYMMDD') ;

works fine, give me 1151001

sunny_talwar

May be you need this YearStart instead of AddYears because AddYears will just add one year to today's date, whereas YearStart will take you to the beginning of the year

=Date(MonthStart(YearStart((Today()-1),-1)),'1YYMMDD')

sunny_talwar

My bad, you do need the same month of last year? If that is the case than what you have is already seems to be working (like Thomas mentioned above)