You need to sign in to do that
Don't have an account?
SIVASASNKAR
calculate Age, Monts, Days from birth day
how to calculate Age, Months, Days from Birthdate to Current Date?
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
how to calculate Age, Months, Days from Birthdate to Current Date?
Date today = Date.Today();
System.Debug('++++' + today.year());
System.Debug('++++' + today.month());
System.Debug('++++' + today.day());
All Answers
Date today = Date.Today();
System.Debug('++++' + today.year());
System.Debug('++++' + today.month());
System.Debug('++++' + today.day());
Thanks for your answer with the help of your methods i develop the code for calculating age,months and remaining days from date of birth.
//THE CODE HELPS FOR CALCULATING AGE, MONTHS AND REMAINING DAYS
Contact c=Trigger.new[0];
date dt=c.Birthdate;
//TO FIND THE AGE
Integer totaldays=dt.daysBetween(system.today());
c.Age__c=(integer)(math.Floor(totaldays/365.2425));
// TO FIND THE MONTHS
if(dt.day()<=(system.today().day()))
c.months__c=system.today().month()-dt.month();
else
c.months__c=system.today().month()-dt.month()-1;
//TO FIND THE REMAINING DAYS
if((system.today().day()== dt.day())||(system.today().day()>dt.day()))
c.Days__c=system.today().day()-dt.day();
else
{
if(math.mod(system.today().month(),2)==0)
c.Days__c=31-(dt.day()-system.today().day());
else
c.Days__c=30-(dt.day()-system.today().day());
}
IF IT IS RIGHT PLEASE SEND ME REPLAY
THANKS AND REGARDS
SIVASANKAR DEVELOPER.