Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

What Is The Method To Calculate Months Between Dates?

Asked by Chloe Burgess Sep 22, 2023 1.4K views 1 answer
Share

About this question

What is the method of calculating the duration between two given dates by utilizing the formula field? Whenever the user denotes the Start Date and End Date, there is a requirement to calculate the Subscription Term. This must be actual months. I need suggestions on what correction must be made in the formula so that The exact months can be calculated between two given dates (including the case of leap year in the middle). For example, if the start date is 1st Jan 2000 and the end date is 15th March 2000, then it must display something as in 2.5 months rather than 3. We are using the formula at present.

IF( IF( SBQQ__SubscriptionTerm__c > 0 , SBQQ__SubscriptionTerm__c , (( SBQQ__EndDate__c - SBQQ__StartDate__c) / 30.4375) ) = 0,

An exact term is needed since the amount that is applicable to products is dependent on the term and it is not possible to round off that term. It can contribute to improper amount calculator. I need a solution and it will be great if anyone can offer a solution utilizing APex as well.

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.