+ Start a Discussion

How to pass integer to Apex SOQL query using date formula??

APEX Gurus,


I'm trying to pass a query using APEX/SOQL, how do I perform a "break" for a date formula? I've tried using double colons, etc, nothing works.. HELP!!



  integer numOfDays = 7;

  Attachment[] lastAttachment = [select Body, Id, Name, ContentType from Attachment where Parentid=:a.Id and CreatedDate = LAST_N_DAYS:numOfDays and CreatedByID !=:a.OwnerID order by CreatedDate DESC]; 


Error: Compile Error: expecting a number, found ':' at line 20 column 141



David VPDavid VP