Please wait, loading...

 

CALCULATE NO OF MONTHS ( FIELD DATE – TODAY ) USING JAVASCRIPT IN MS CRM 2011 , 2013

February 15, 2014
/// <reference path=”XrmPage-vsdoc.js” />
function calMonths() {
    //get the startdate field value in variable
    var startday = xrm.page.getAttribute( “fieldname”).getValue();
    // get todays date in variable
    var today = new date();
    // get the value of one day in (mili_second * second * min * hours)
    var one_dat = 1000 * 60 * 60 * 24;
    // get no of days in month
    var one_month = 30;
    //get time
    var starttime = startday.getTime();
    var currenttime = today.getTime();

    var diffrence = math.abs(currenttime – starttime);
    noofdays = Math.round(diffrence / one_day);
    noofmonths = Math.round(noofdays / one_month);
    // set the noofmonths value in field
    xrm.page.getAttribute( “new_calmonths”).setValue(noofmonths);

}


SOURCE : JUST2CODE.IN
Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651
Microsoft Dynamics Community Profile

Learn more