Knowledge: Manipulating Dates with Live Formula
Back
Knowledge
Title*Manipulating Dates with Live Formula
ManualTips and Tricks
Created22/04/2022
DetailBelow is an example of converting en-GB date format of dd/mm/yyyy to date for manipulation and adding number of months to a date.
In the live formula you will be calling something like dateaddmonth('[DateFieldx]',numberofmonths)
The matching function below will need to be added to the Input form header in the JavaScript section.
function dateaddmonth(invalue,addmonth){
try
{
var parts = invalue.split("/");
var options = {
year: "numeric",
month: "2-digit",
day: "2-digit"
};
var d1 = new Date(Number(parts[2]), Number(parts[1]), Number(parts[0]));
d1.setMonth(d1.getMonth() + addmonth-1);
return d1.toLocaleDateString("en-GB",options);
}
catch(e)
{
return e.Message;
}
}
Please note this is an example and changes will be required for your environment or requirement e.g. you may need to add years or combine two dates.
Additional Manual Locations
| Administration | Data Rooms | Forms Design |