I'm trying to write a SOQL query that uses " WHERE Date__c = THISYEAR() " but that isn't working... I think what i'd need to do is create a variable:

Integer currentyear = System.Today().year() 

however I feel like that isn't optimal... what's the best way to do this?

1 Answer 1


You can use Date Literals like in the below query

SELECT Id FROM Opportunity WHERE CloseDate = THIS_YEAR

THIS_YEAR : Starts 00:00:00 on January 1 of the current year and continues through the end of December 31 of the current year.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .