Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Auto populate week commencing date

Community Beginner ,
Oct 11, 2024 Oct 11, 2024

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.

TOPICS
PDF forms

Views

263
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Oct 11, 2024 Oct 11, 2024

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);
}

View solution in original post

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2024 Oct 11, 2024

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);
}

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 11, 2024 Oct 11, 2024

Copy link to clipboard

Copied

LATEST

Thank you! That works perfectly.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines