Copy link to clipboard
Copied
I would like to populate a field with a week commencing date with Monday being the week commencing date from another date field, my dates are formatted dddd, dd mmm yyyy.
Assuming your other date field is called "Date", enter the following custom calculation script in the field you want to populate from it's value:
if(!this.getField("Date").value)
{event.value=""}
else
{
var date=util.scand("dddd, dd mmm yyyy",this.getField("Date").value);
var day=date.getDay();
var diff=0;
if(day==0){diff=1}
else if(day>1)
{diff=1-day}
date.setDate(date.getDate()+ diff);
event.value = util.printd("dddd, dd mmm yyyy", date);
}
Copy link to clipboard
Copied
Assuming your other date field is called "Date", enter the following custom calculation script in the field you want to populate from it's value:
if(!this.getField("Date").value)
{event.value=""}
else
{
var date=util.scand("dddd, dd mmm yyyy",this.getField("Date").value);
var day=date.getDay();
var diff=0;
if(day==0){diff=1}
else if(day>1)
{diff=1-day}
date.setDate(date.getDate()+ diff);
event.value = util.printd("dddd, dd mmm yyyy", date);
}
Copy link to clipboard
Copied
Thank you! That works perfectly.