+ Start a Discussion
Dutta SouravDutta Sourav 

How to Calculate Age in Day?

There is a date field, for inserting date of birth.

There is another button to calculate age (in days) which will be displayed below.

How to do that?

Best Answer chosen by Dutta Sourav
goabhigogoabhigo
Can you try this forumal - FLOOR((TODAY() - DateofBirth__c)/365.2425)

There are multiple posts in Discussion Forums and Success community for the same. Try searching out if this doesn't work.

--
Abhi

If my answer helps to solve the issue/problem/doubt, please mark it as Best Answer; so that people who are stuck in the similar issue get benefitted. 

All Answers

ra811.3921220580267847E12ra811.3921220580267847E12
Hi,


{!requireScript("/soap/ajax/26.0/connection.js")}
    var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1; //January is 0!

    var yyyy = today.getFullYear();
    if(dd<10){
        dd='0'+dd
    } 
    if(mm<10){
        mm='0'+mm
    } 
    var today = dd+'/'+mm+'/'+yyyy;
    
    

var account = new sforce.SObject("Account");

var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
    var firstDate = today;
   var secondDate = selecteddate(YOUR DATE);

var diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay)));
    
account.id = //set Record Id here, potentially get it from the URL ?id= param

account.field__c = value;
account.dateField=diffDays;
sforce.connection.update([account]); 
window.location.reload(); //to reload the window and show the updated values
goabhigogoabhigo
Can you try this forumal - FLOOR((TODAY() - DateofBirth__c)/365.2425)

There are multiple posts in Discussion Forums and Success community for the same. Try searching out if this doesn't work.

--
Abhi

If my answer helps to solve the issue/problem/doubt, please mark it as Best Answer; so that people who are stuck in the similar issue get benefitted. 
This was selected as the best answer
goabhigogoabhigo
Do you need further help on this? Were you able to solve?
Dutta SouravDutta Sourav

yes, It is solved. 

But further suggestions are welcome.

goabhigogoabhigo
I don't understand what else you would need. Can you tell me what else you need to know?