0

//Error: Line 10: Date arithmetic expressions must use Integer or Long arguments

trigger Trigger1_3 on Account (before insert,before update) {

    if(Trigger.isInsert)
    {
        for(Account acc: Trigger.New)
        {
            if(!isEmpty(acc.Start_Date__c))
            {

              if((System.today()- acc.Start_Date__c) < 0)
             {
                 acc.Status__c='In Progress - Violated';
             }
                else
                {
                    acc.Status__c='In Progress';
                }
           }
            else
            {
                 acc.Status__c='Not Started';
            }
       }     
    }

}
1
  • 1
    I believe you want to check if the start date is greater than today? Why cant you just do System.today() > acc.Start_Date__c OR System.today() < acc.Start_Date__c ? Commented Nov 21, 2016 at 6:41

1 Answer 1

1

You can't calculate the day's differences by simply subtracting two dates. You need to use daysBetween() method.

Below is the sample code:

Date yesterday = Date.today().addDays(-1);
System.debug('The difference is: ' + Date.today().daysBetween(yesterday));

You must log in to answer this question.

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