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

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

You may also like

Leave a Comment