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
SIVASASNKARSIVASASNKAR 

Triggers

I want find the Age of Employee With the help of Trigger Based on Date of Birth and Todays Date?

Navatar_DbSupNavatar_DbSup

Hi,


You have to use the daysbetween method of date to achieve this.

 

Try the below code as reference:

 

Trigger AgeCalculation on Contact (before insert,before update)
{
Date dt=trigger.new[0].birthdate;
Integer age= dt.daysbetween(system.today())/365;
System.debug('@@@@@@@@@@@@@@@@@@' +age);
}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

amit_sfdcT-2amit_sfdcT-2

Hi Siva,

 

If you satiesfied with the above answer, please close this discussion.

 

Feel free to contact me, if you have any queries.

 

Regards,

Amit Kumar Gupta

Salesforce.com