Skip to main content
Inspiring
March 28, 2022
Answered

CURRENT DATE & DEADLINE DATE

  • March 28, 2022
  • 1 reply
  • 26402 views

Attached is a form I want the deadline to always be the 5th of the upcoming month. e.g., if the current date is 27th of march, the deadline should always be one month ahead. but in this case, the day would always be 5th of the upcoming month. I hope this can be done!

Thanks in anticipation for a quick response.

This topic has been closed for replies.
Correct answer Nesa Nurani

I see you don't have field for deadline date, so create a field I named it "Deadline_Date" and add new document level script using this:

var month = util.scand("dd-mmm-yyyy", new Date());
month.setMonth(month.getMonth() +1);
var str = util.printd("dd mmmm, yyyy", month);
var newDate = "05"+str.slice(2);
this.getField("Deadline_Date").value = newDate;

 

Here is your file with everything above added:

https://drive.google.com/uc?export=download&id=1gm7aW8xUlJx4tbyVimvQ6sW1M9Eybyic 

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
March 28, 2022

I see you don't have field for deadline date, so create a field I named it "Deadline_Date" and add new document level script using this:

var month = util.scand("dd-mmm-yyyy", new Date());
month.setMonth(month.getMonth() +1);
var str = util.printd("dd mmmm, yyyy", month);
var newDate = "05"+str.slice(2);
this.getField("Deadline_Date").value = newDate;

 

Here is your file with everything above added:

https://drive.google.com/uc?export=download&id=1gm7aW8xUlJx4tbyVimvQ6sW1M9Eybyic 

saka5FD5Author
Inspiring
March 29, 2022

There is a problem I didn't anticipate with the above script and needed help with.

I would want it to be amended in such a way that the "Deadline_Date" would only change to the upcoming month when the "Current_Date" crosses the Deadline_Date by one I.e., on the 6th.

I attached the form again.

Thanks in anticipation for a quick response.

Nesa Nurani
Community Expert
Community Expert
March 29, 2022