Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
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!

15 Replies
Anonymous
Not applicable
Author

I am using the Date function to convert it.

Capture.PNG

sunny_talwar

I don't understand.... this should work

Date(AddMonths(Subscription_Start_Date__c, Subscription_Duration__c)) as test

Anonymous
Not applicable
Author

Doesn't work

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

Anonymous
Not applicable
Author

num# worked

martinscottquinn
Contributor
Contributor

You are trying to use a field (with the __C)  that's been renamed. Try using [Subscription Start Date] instead in your AddMonths statement.