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 ? Nov 21 '16 at 6:41
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));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.