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

ADDMONTHS() implementation

I need to use ADDMONTHS() but as per my knowledge it needs a proper date as input. I have the month and year as separate variables.

How to implement the function??

9 Replies
MK_QSL
MVP
MVP

Something like below..

=AddMonths(MakeDate(Year(Today()),Month(Today()),1),1)

PrashantSangle

Hi,

As Manish Said You have to first Make Date Using MakeDate()

Then use AddMonth(DateField,1)

Like,

MakeDate(Year,Month,01) as NewDate,

AddMonths(NewDate,1) as NextMonth

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Not applicable
Author

Hi,

Ex:

Year : 2014

Month : Mar

MonthNum : 3 or 12 (If normal/Finance)

MakeDate:

=Date(MakeDate('2014','3'),'DD/MM/YYYY')

AddMonths:

=Date(AddMonths(Date(MakeDate('2014','3'),'DD/MM/YYYY'),2),'DD/MM/YYYY')

Not applicable
Author

Thanks for replying... but sorry it dint work

mansi_dv
Contributor
Contributor

What if I have year and month selected by user? I cant hardcode like 2014 and 3.

Not applicable
Author

Replace those static data with your Year and MonthNum fields

Note: When user selects any month the corresponding moonthnum we can get

mansi_dv
Contributor
Contributor

I tried it, but no use.

Actually I am using the maxstring function to fetch month from user. So I created monthnumber in a variable using

NUM(Month(MaxString({[new]} [Month])))

where new is my alternate state.

Then I used this variable in the expression given by you in place of 3, but no output.

Not applicable
Author

As you said that you have variables for month and year

means your data contains Month and Year fields.Corresponding that Month,Create a MonthNum field by using applymap/Join

Ex:

MapTable:

Mapping Load * Inline [

Month, MonthNum

Apr, 1

May, 2

Jun, 3

Jul, 4

Aug, 5

Sep, 6
Oct, 7

Nov, 8

Dec, 9

Jan, 10

Feb, 11,

Mar, 12

];

YourDataTable:

Load *,

ApplyMap('MapTable',Month) as MonthNum

From ********;

After that create variables as i said and it will work

mansi_dv
Contributor
Contributor

Thanx