Skip to main content

Posts

Showing posts from January, 2018

get Date of birth in text JavaScript Dynamics CRM

function getAge(fromdate, todate) {     var currentDate = new Date();     if (todate) todate = new Date(todate);     else todate = new Date();     if (fromdate) fromdate = new Date(fromdate);     else fromdate = new Date();     if (fromdate.valueOf() > todate.valueOf()) {         // if future date     } else {         var age = [],             fromdate = new Date(fromdate),             y = [todate.getFullYear(), fromdate.getFullYear()],             ydiff = y[0] - y[1],             m = [todate.getMonth(), fromdate.getMonth()],             mdiff = m[0] - m[1],             d = [todate.getDate(), fromdate.getDate()],             ddiff = d[0] - d[1];         if (mdiff < 0 || (mdiff === 0 && ddiff < 0)) --ydiff;         if (mdiff < 0) mdiff += 12;         if (ddiff < 0) {             fromdate.setMonth(m[1] + 1, 0);             ddiff = fromdate.getDate() - d[1] + d[0];             --mdiff;         }         if (ydiff > -1) age.push(ydiff + ' year' + (ydiff &g