function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Riyaju.ax1518Riyaju.ax1518 

How do I check Parameter year as Greater then or equal to current_year?

How I check in Apex Class, as given  string year parameter is grater then or equal to current year

APEX

List<Contact> contactList = [SELECT firstname,lastname,Current_Fees_Due__c,Id,A_Level_Year__c from Contact WHERE Contact_Type__c = 'Student' AND Tuition__c='Customer' AND A_Level_Year__c>='%Current Year%'

ORDER BY Name ASC];

 

Note: A_Level_Year__c = '2012' [ parameter is strin g format]

RamitRamit

Hi,

 

Find the current year by using Date.today() and then use it in your query. 

 

Please see below the code :

 

String str_current_year = String.Valueof(date.today()).substring(0,4);

List<Contact> contactList = [SELECT firstname,lastname,Current_Fees_Due__c,Id,A_Level_Year__c from Contact WHERE Contact_Type__c = 'Student' AND Tuition__c='Customer' AND A_Level_Year__c>=:str_current_year
ORDER BY Name ASC];

 

RamitRamit

Hi,


Did the solution provided helped ? Let me know in case of any issues.

 

If the solution helped then, mark it as solution.