You need to sign in to do that
Don't have an account?
yakup 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
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
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.