function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
t999t999 

Help with Salesforce Formulae

Start_date__c = 02/06/2015 (Feb 6, 2015)
end date - 02/05/2016 (Feb 5, 2016)
We will be billing our customer every month. I am trying to capture Month_billing_date. For eg
 Month_billing_date__c for Feb 6 - March 5 should be March 5
 Month_billing_date__c for March 6 - April 5 should be April 5.
I reasearched various portals and resources I am not able to achieve what I want. Please help.
Thanks in advance!
Neetu_BansalNeetu_Bansal
Hi,

Try this code, here Start_Date__c is a Date field and this is the formula for End date.
IF( AND( MONTH(Start_Date__c) == 1, DAY(Start_Date__c) < 28 ),
DATE(YEAR(Start_Date__c), MONTH(Start_Date__c) + 1, DAY(Start_Date__c) + 1),
DATE(YEAR(Start_Date__c), MONTH(Start_Date__c) + 2, 1))
Let me know, if you need any other help.

Thanks,
Neetu
t999t999
Hey Neetu, 
Thanks for replying. But your formulae is not giving me the correct answer. Since I am trying to capture billing date for this month. So answer should be November 5,2015. But your formulae is giving me April 1, 2015 (4/1/2015). 
So if Start_date__c = 02/06/2015 (Feb 6, 2015) and end date - 02/05/2016 (Feb 5, 2016) then current billing period is Oct 6 2015 - Nov 5, 2015. That's why Month_Billing_date should be Nov 5,2015.

-Tushar
Jorge OrtegaJorge Ortega
Try this, maybe you must control with a CASE statement (instead this IF) the firsts and lasts days of the month
IF( DAY(Start_Date__c) = 1, DATE(YEAR(Start_Date__c), MONTH(Start_Date__c) + 1, 1),
DATE(YEAR(Start_Date__c), MONTH(Start_Date__c) + 1, DAY(Start_Date__c) ) - 1 )

You could add or substract days from a date value, as they were integers.

Hope this helps
Jorge