Answered
Auto populate week commencing date
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.
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);
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.