Hi All

I’m bit new to JScript, trying to calculate year, month and date from DOB field, I picked up the link from below, and tried it, could any one suggest if this is correct as I’m experiencing error

community.dynamics.com/.../get-month-day-year-from-a-date-field-in-crm-using-javascript

osplitDateandTime = {
    splitDateofBirth : function(exeecutionContext){
    //debugger;
    var formcontext = executionContext.getFormcontext();
    if(formcontext.getAttribute("new_dateofbirth")){
    var datefieldValue = formcontext.getAttribute('new_dateofbirth').getValue();

    if(dateFieldValue !==null){
    var yearDOB = dateFieldValue.getFullYear().toString();
    var monthDOB = (datefieldValue.getMonth()+ 1).toString();
    var dayDOB = dateFieldValue.getDate().toString();

    FormContext.getAttribute("dcuk_year").setValue("yearDOB");
    FormContext.getAttribute("dcuk_monthdob").setValue(("0"+ monthDOB).slice(-2));
    FormContext.getAttribute("dcuk_datedob").setValue(("0"+ dayDOB).slice(-2));

    } else {

        FormContext.getAttribute("dcuk_year").setValue(null);
        FormContext.getAttribute("dcuk_year").setValue(null);
        FormContext.getAttribute("dcuk_year").setValue(null);
    
    }
    }
    }
};

Thanks

Jag