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: 
Anonymous
Not applicable

AddMonths function

Hi,

I have a start date 02/15/2017. I need to add number of months to get the end date. Suppose no of months=12 will give me the end date 02/15/2018. The number of months will come from a field. I know the function AddMonths but it's only working when I am giving the number of months explicitly.

AddMonths(date(Subscription_Start_Date__c),12) is working.

But how do I write the function if the number of months is coming from another field?

AddMonths(date(Subscription_Start_Date__c),Subscription_Duration) doesn't work.

Capture.PNG

Thanks!

1 Solution

Accepted Solutions
sunny_talwar

Is Subscription_Duration__c a number field is the last thing I can ask you to check.... otherwise I have no idea... Unless you are able to share a sample, I have no idea why it isn't working

Date(AddMonths(Subscription_Start_Date__c, (Subscription_Duration__c * 1))) as test

View solution in original post

15 Replies
sunny_talwar

Where is this used? May be this:

AddMonths(Date(Subscription_Start_Date__c), Max(Subscription_Duration))

Anonymous
Not applicable
Author

In the script. Gives an error saying invalid expression.

sunny_talwar

I don't see why your original expression won't work in the script. Do you have Subscription_Start_Date__c and Subscription_Duration in one table when you are doing this AddMonths calculation???

Anonymous
Not applicable
Author

Yes.

Capture.PNG

sunny_talwar

How about this?

AddMonths(Date#(Subscription_Start_Date__c, 'MM/DD/YYYY'), Subscription_Duration__c)

Anonymous
Not applicable
Author

Not working

sunny_talwar

Why don't you paste the screenshot of the error you have received

Anonymous
Not applicable
Author

Writing the max function is giving error while reloading the script 'Invalid expression'. Omitting the max function, the field 'test' is not displaying any values.

Capture.PNG

Capture.PNG

sunny_talwar

‌can you run your script without this and send a screenshot for the Subscription_Start_Date__c field.... seems like QlikView doesn't interpret as a date field.

Best,

Sunny