title: How to create a custom object with apex for apex scheduler? (Compile Error: Comparison arguments must be compatible types)
body: <p>I am new to apex and am trying to build an apex schedule class that runs everyday. If the account review date for commisions is two weeks (14 days) away the scheduler will send an email to our Sales Department.</p>
  
  <p>I'm almost done with the program but I keep getting this error:</p>
  
  <p>Error: Compile Error: Comparison arguments must be compatible types: Schema.SObjectField, Date at line 9 column 9</p>
  
  <p>Here is my code: </p>
  
  <pre><code>global class AccountReviewScheduler implements Schedulable
  {
      global void execute (SchedulableContext ctx) 
      {
          sendEmail();
      }
  public void sendEmail()
  {
      if (Account__r.Next_Account_Review_Date__c == System.today().addDays(14))
      {
          Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
          Mail.setTemplateId('00XF0000000LfE1');
          Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail });
      }
  }
  
  }
  </code></pre>
  
  <p>I did some research and a commenter on another discussion board told me that it's not working because
  Account__r.Next_Account_Review_Date__c is just a field.</p>
  
  <p>I have to use it with a record to make it have a value. Then I can compare that value with system.today().</p>
  
  <p>I'm not sure what that means....create a custom object? I'm not sure how to do this. Here is my revised code I'm having trouble with. Here is my revised code: </p>
  
  <p>Here is the revised code(asterisks ** denote change)</p>
  
  <pre><code>global class AccountReviewScheduler implements Schedulable
  {
      global void execute (SchedulableContext ctx) 
      {
          sendEmail();
      }
  public void sendEmail()
  {
      **CustomObj__c co = [select Account__r.Next_Account_Review_Date__c from CutomObj__c limit 1];**
      **if(co.Account__r.Next_Account_Review_Date__c == system.today().addDays(14))** 
      {
          Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
          Mail.setTemplateId('00XF0000000LfE1');
          Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail });
      }
  }
  
  }
  </code></pre>
  
  <p>Changes are shown in bold...I know the custom obj code might be wrong...I got it off someone else and I'm not sure what to do.</p>
  
  <p>NOTE: Time based workflows will not work here because this email has to occur every year (for many years) 14 days before the account review date. Time based workflows will work ONCE after they are set to trigger one year, but do not repeat. They do not recur by design. See: <a href="http://success.salesforce.com/questionDetail?qId=a1X30000000JnPMEA0" rel="nofollow">http://success.salesforce.com/questionDetail?qId=a1X30000000JnPMEA0</a></p>
  
  <p>I have read the scheduling documentation: <a href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm" rel="nofollow">http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm</a></p>
  
  <p>and gone over the Apex workbook tutorial:http://blogs.developerforce.com/developer-relations/2010/02/spring-10-saw-the-general-availability-of-one-of-my-favorite-new-features-of-the-platform-the-apex-schedulerwith-the-apex-s.html as well as tutorial 14 in the official Apex guide but I still am having trouble.</p>
  
  <p>Any help/insight into my code/links to new resources would be greatly appreciated. </p>