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

String dateOfToday = String.valueOf(Date.today().year());

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 

2x Salesforce MVP | Platform Champion | 18x Salesforce Certified | MuleSoft Certified | 8x Trailhead Ranger | TechForce Services | Sydney | Australia

Leave a Reply

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

*