Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
dhavalvyas
Contributor III
Contributor III

Doubt in Add months

I am doing functions for qilkview.

I have doubt in following add month() function.

Addmonth('2003-02-28',1,1) returns ('2003-03-31')

I comes to know that for month 02 it adds 1 in it and returns an 3rd month but for date 28 how it returns 31 ??

16 Replies
sunny_talwar

You are using mode = 1 (your last parameter)

=Addmonth('2003-02-28',1,1)

Try without the extra 1:

=Addmonths(MakeDate(2003, 2, 28),1)

Also read here:

addmonths ‒ QlikView

dhavalvyas
Contributor III
Contributor III
Author

But I want it with mode 1 ??

dhavalvyas
Contributor III
Contributor III
Author

Just only tell about how it returns 31 ? What logic applied here

sunny_talwar

So, unfortunately then the help specify that this is the output you are going to get

Capture.PNG

dhavalvyas
Contributor III
Contributor III
Author

I cant understand it from help ? I didn't get any logic behind it ?

sunny_talwar

Logic is right here

Capture.PNG

Read the second line.... If the input date is the 28th or above and mode is set to 1, the function will return a date which is the same distance from the end of the month as the input date... Does it make sense?

sunny_talwar

You don't understand what this means?

"If the input date is the 28th or above and mode is set to 1, the function will return a date which is the same distance from the end of the month as the input date"

dhavalvyas
Contributor III
Contributor III
Author

so for '20003-01-29',1,1 returns '2003-02-26' how ???

sunny_talwar

Because 29th Jan is 2 days before the end of the month (31 - 2 = 29)... same way 26th is 2 days before the end of the month in feb (28-2 = 26).... Does this make sense

If it still doesn't then I am afraid I don't have a better way to understand. Help cannot be more clear in specifying what they are doing here

"If the input date is the 28th or above and mode is set to 1, the function will return a date which is the same distance from the end of the month as the input date"