How to get the number of days difference between two dates
In a number component you can set the defaultValue using the getDateDiff function. Example below. You should also change the “recalculateDefaultValueWhenDataPathChange” property to include the two date dataPaths
Here is an example of the configuration set up in a number component:
{
"name": "taskOneDateDifference",
"label": "Date Difference",
"description": "",
"defaultValue": "=getDateDiff({$.taskOne.dateOne.date:JSON}, {$.taskOne.dateTwo.date:JSON}, 'day')",
"dataPath": "$.taskOne.dateDifference",
"dataSource": "work",
"isRequired": false,
"isReadOnly": false,
"isHidden": false,
"width": "col-6",
"condition": "",
"dataKey": "data",
"recalculateDefaultValueWhenDataPathChange": [
"$.taskOne.dateOne",
"$.taskOne.dateTwo"
],
"validation": [],
"dataPathUpdate": "Manual",
"properties": {
"inputType": "number"
}
}