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

Doubts in AddMonths function.

Hi All,

I read the AddMonths functions in the help file. I could not understand the use of [Mode] parameter. What is the use of this Parameter?

I had gone through the examples given in the help file, but i can't understand perfectly.

addmonths ('2003-01-29',1,1) returns '2003-02-26'
addmonths ('2003-01-29',1,0) returns '2003-02-28'

Look at the above examples, by adding mode the result has changed. How?

Regards,

Raghu.

1 Solution

Accepted Solutions
stephencredmond
Luminary Alumni
Luminary Alumni

Hi Raghu,

With the 0 in the Mode, you get it adding 1 month to 29th January - it will come up with 29th February which, unless it is a leap year, is not a valid date so it gives you the last valid date of that month.

With 1 in the month it works out that the 29th January is the 3rd last day of January - the 3rd last day of February is the 26th.

Regards,

Stephen

View solution in original post

4 Replies
stephencredmond
Luminary Alumni
Luminary Alumni

Hi Raghu,

With the 0 in the Mode, you get it adding 1 month to 29th January - it will come up with 29th February which, unless it is a leap year, is not a valid date so it gives you the last valid date of that month.

With 1 in the month it works out that the 29th January is the 3rd last day of January - the 3rd last day of February is the 26th.

Regards,

Stephen

Not applicable
Author

Thanks Stephen,

I got it..

Thanks,

-Raghu

siva_boggarapu
Creator II
Creator II

Hello Stefan,

Could Please give me bit more explanation on this what is "mode" can do?

vikasmahajan

Hi

Stephen

Please check my expression using Mode my problem is solved

I used following expression and use 1 mode for hadling leap year

addmonths(max({$<FiscalYear={$(=max(FiscalYear))}>}[Posting Date]),-12,1))

http://community.qlik.com/message/325264#325264

Please reply whether this is correct way.

Thanks

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.