23:38 -
2 comments
JavaScript Code for Age Calculation from Date of Birth | MS CRM
Age Calculation:
Add Java Scripts code as on change of Date Of Birth field value Then you will get age value when ever Date Of Birth value change.
function CalcAge()
{
var now = new
Date(); //Todays Date
var birthday =
Xrm.Page.getAttribute("new_dob").getValue(); //Get the Date of Birth
value
var diff =
now.getMonth() - birthday.getMonth();
//Check to see if Birthday has already passed
if (diff > -1) //If Birthday has already occurred
{
var bd1 =
now.getFullYear() - birthday.getFullYear();
//set the age
attribute
Xrm.Page.getAttribute("new_a").setValue(bd1.toString());
}
else //If Birthday
has not already occurred
{
var bd2 =
now.getFullYear() - birthday.getFullYear() - 1;
Xrm.Page.getAttribute("new_a").setValue(bd2.toString());
}
}
2 comments:
Thanks to the author. This is what i was looking for several hours. However! i have found completely automated Microsoft Excel Formula for Age calculation, here is the link to complete video tutorial. Excel Perfect Age Calculator Magic Formula + Ready Worksheet Download
tq
Post a Comment