function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CyclebiffCyclebiff 

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!!

 

Query:

  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