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
balaji_SFDCbalaji_SFDC 

Getting year in TODAY() Function

Hi Experts,

In my Org I want to Calculate the Difference Between (year in today date - year in date of birth (custom field)).For
this i wrote below code

YEAR({!TODAY()})-YEAR(objcal.DateOfBirth__c)

When i run this program it Shows error      " Compile Error: expecting a right parentheses, found '{' at line 74 column 28 "

Anyone Please Help me How to get out of this problem
RIyas BasheerRIyas Basheer
Hi Venkatesh,

 Just try  {!YEAR(TODAY()) - YEAR(objcal.DateOfBirth__c)}
Chidambar ReddyChidambar Reddy
Hi Venkatesh,
Are you writing this in a program? or in a formula field?? APEX doesn't support YEAR(date) like formula.

If it is in the program : 

integer age = system.today().year() - ((date)objcal.DateOfBirth__c).year();
OR
integer age = Date.today().year() - ((date)objcal.DateOfBirth__c).year();

Thank you
Choose it as best answer if it resolved your issue.