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
yakup kaygusuzyakup kaygusuz 

integer division doesn't work

I have a method that does integer division on two numbers but seems to always return zero heres the code
while(forcastTo>=sub.miiFinance__Date_Next_Billing__c)
                 {
                     Integer a = (sub.miiFinance__Date_Next_Billing__c.daysBetween(forcastTo));
                 calculatedDays += (a/7);
                 sub.miiFinance__Date_Next_Billing__c = sub.miiFinance__Date_Next_Billing__c.addDays(term);
}

the values i get from the date operation are 5,12,19,26
Hargobind_SinghHargobind_Singh
Hi Yakup,

If the result of Integer division is a decimal, Salesforce would return you the Floor Integer number, 

e.g.: 6/7, which is approx 0.85 will give you 0
and 12/7, which is approx 1.71 will give you 1. 

You should check the values and see what is your expected result.