Count of age to convert to 1 year, when it's 6 motnhs
I am looking for a solution on how to update the script, so that it would give me a value of 1, when it is equal to 6 months. If the value is less than 6 months, to have 0. Also, I do not know how to make that the field would allow saving fixed value.
Here is the script I am using in 'Custom Calculation' box:
event.value = "";
var dobValue = getField("Textfield-49").value;
if (dobValue!="") {
var dob = util.scand("dd/mm/yyyy", dobValue);
var today = new Date();
var age = today.getTime() - dob.getTime();
// compute age in milliseconds
var nAgeMilliseconds = today.getTime() - dob.getTime();
var nAgeYears = ( age / (1000 * 60 * 60 * 24 * 365.2425) - 0.005);
event.value = Math.floor(nAgeYears);
}
