0

Here is the full Error message:

Method does not exist or incorrect signature:Line: 1, Column: 1 Method does not exist or incorrect signature: CompareNewAndOldFiscalPeriod.compareMonths(Integer, Integer)

When trying to execute the code below:

More generally does anyone have a guide on how to trouble shoot this error. It crops up a lot and seems to have completely different causes in every case.

Execute Anonymous:

CompareNewAndOldFiscalPeriod.compareMonths(11/1/2015,1/1/2016);

Class

public class CompareNewAndOldFiscalPeriod {

//Set  up to see if the change in and end date results is moving the opportunity to a different fiscal month.  This is used as a measure of pipeline quality
//Designed to be called by a flow that is evaluating other changes in oppty data.

//find fiscal month of old close date
public static Boolean compareMonths(date OldClose, date NewClose){
    List<Period> OldPeriod= [SELECT Number,Id From Period WHERE type = 'Month' AND StartDate < =:OldClose AND EndDate>=:OldClose LIMIT 1];
    period Per=New period();
    Integer OldMonth=0;
    Per=OldPeriod.get(0);
    OldMonth=per.Number;  


    //find fiscal month of new close date  
    List<period> NewPeriod=[SELECT Number,Id From Period WHERE type = 'Month' AND StartDate < =:NewClose AND EndDate>=:NewClose LIMIT 1];
    period Per2=New period();
    Integer NewMonth=0;
    Per2=NewPeriod.get(0);
    NewMonth=per2.Number;   

    system.debug('New fiscal month is' + NewMonth);

    //compare and return a verdict about whether or not this will count as a change in Fiscal Period
    Boolean verdict=false;
    If(NewMonth>OldMonth){
        verdict=true;

        System.debug('Verdict is '+ verdict);
    }
  return verdict;
}

}
2
  • from where you are calling this method ? As per the error message you are passing integer but this method accept date as data type.
    – Himanshu
    Commented Mar 12, 2016 at 20:01
  • Execute Anonymous: CompareNewAndOldFiscalPeriod.compareMonths(11/1/2015,1/1/2016); Commented Mar 12, 2016 at 20:06

2 Answers 2

1

You will call your method in following format.

Date startDate = date.parse('11/1/2015');
Date endDate = date.parse('1/1/2016');
compareNewAndOldFiscalPeriod.compareMonths(startDate,endDate); 
0
1

Your signature takes (Date, Date) but you are passing (Integer, Integer).

Integer a = 1/1/2015;
Integer b = 1/1/2016;
myMethod(a, b); // incorrect

Date x = Date.newInstance(2015, 1, 1);
Date y = Date.newInstance(2016, 1, 1);
myMethod(x, y); // correct

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .