How to get the current year records from custom object where year is in a text field?

String dateOfToday = String.valueOf(;

Then your SOQL would include this in the where clause.

Note: Use the API name of your field

WHERE Sales_Year__c = :dateOfToday

Written by 

Salesforce MVP | Lightning Champion | 17x Salesforce Certified | Application Architect | 7x Trailhead Ranger | Techforce Services | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *