+ Start a Discussion

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


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();
integer age = Date.today().year() - ((date)objcal.DateOfBirth__c).year();

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