- When using date literals in SOQL, you do not need to use the colon
: that you normally use when referring to variables.
- You should use the literal
LAST_N_QUARTERS:n. So, for your
case it would be
So your final SOQL should be
[Select Name From Invoice_Line_Item__c Where Invoice_Date__c = LAST_N_QUARTERS:4];
Here is the documentation you can look at
In looking closer at your question, it looks like you don't want the past 4 quarters but rather the fourth quarter of a date in the past (in your case, 1 year ago). If you want to do this, then date literals likely wont be the way to go.
I would create new date instances, and use those in your SOQL. Something like this
Date beginDate = Date.newInstance(2012,10,1);
Date endDate = Date.newInstance(2012,12,31);
list<Invoice_Line_Item__c> invoices = [Select Name From Invoice_Line_Item__c Where
Invoice_Date__c >=: beginDate and Invoice_Date__c <=: endDate];