Copy link to clipboard
Copied
I am trying to enter a single pay period start date that leads to the start and end dates for the next 27 pay periods.
for the starting pay period I used the following script in each text field cusom calculation script adjusting the field to pull from
var d = util.scand("mm/dd/yyyy", this.getField("PPWK2End1").valueAsString);
var theTime = d.getTime () ;
var oneDay = theTime + 1*24*3600*1000;
var dd = new Date(oneDay);
event.value = util.printd("mm/dd/yyyy", dd);
then I used the following to get the payperiod end date
var d = util.scand("mm/dd/yyyy", this.getField("PPWK1Start2").valueAsString);
var theTime = d.getTime () ;
var oneDay = theTime + 13*24*3600*1000;
var dd = new Date(oneDay);
event.value = util.printd("mm/dd/yyyy", dd);
The problem is that the dates do not populate beyond the second pay period and the calculations seem to forget there are 31 days in october when it does run correctly.
Please help! there has to be an easier way!
Copy link to clipboard
Copied
Use this:
var s = this.getField("PPWK1Start2").valueAsString;
if (s=="") event.value = "";
else {
var d = util.scand("mm/dd/yyyy", s);
d.setDate(d.getDate()+13);
event.value = util.printd("mm/dd/yyyy", d);
}
Copy link to clipboard
Copied
You want to populate 27 days from start date?
Why not use getDate() and setDate() instead of variable oneDay?
Copy link to clipboard
Copied
the PPWK2End is 13 days past PPWK1Start and the next row is the start of a new 2 week pay period
Copy link to clipboard
Copied
Use this:
var s = this.getField("PPWK1Start2").valueAsString;
if (s=="") event.value = "";
else {
var d = util.scand("mm/dd/yyyy", s);
d.setDate(d.getDate()+13);
event.value = util.printd("mm/dd/yyyy", d);
}
Copy link to clipboard
Copied
this totally worked!
I ended up going off of the first dte for each other date so there was some math involved but it works perfectly!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now