You need to sign in to do that
Don't have an account?
KevinRussell
Count records having date within the past year
I'm trying to count records having a date within the past year. I'm having trouble with the date comparrison.
My error: Compile Error: unexpected token: 'CutoffDate' at line.........
I don't know how to compare the DateTime record field: Start_Date_Time__c against a date variable.
Thanks for any help.
Kevin
trigger Contacts_Attended_Event_Within_Past_Year_Checkbox_test on Interaction__c (after insert, after update) { // Store Contact record ID map< id, contact > contacts = new map< id, contact >(); date todaysDate = date.today(); date CutoffDate = todaysDate.addDays(-365); Integer recordcount = [select count() from Interaction__c where Start_Date_Time__c > CutoffDate ];
Add a colon in front of your date binding variable like so:
All Answers
Add a colon in front of your date binding variable like so:
You're just missing a : before the variable CutoffDate. Need that since it's a variable within Apex rather than an object column/field.
Integer recordcount = [select count() from Interaction__c where Start_Date_Time__c > :CutoffDate ];