7 Replies Latest reply on Apr 1, 2017 10:53 AM by markm24124658

    PDF Form - Date increase / decrease - Does not always run in time

    markm24124658

      Hello fellow Acrobat users ...

       

      This is my first post, so please forgive me if i am too detailed or not detailed enough

       

      My question is ... Why does the formula not work consistency?

      Thank you very mush in advance for your help

       

       

       

      I have created a form that allow a single field to populate other fields

       

      Field 1       A date is entered e.g. 01- apr 2017

      Fields 2-8 - Whatever is entered into Field 1 is auto-populated into fields 2-8 ... minus 1 day starting from 8 back through to 2, incrementing

      Using the format "dd - mmm - YYYY" ... mmm is Caps on first letter

      e.g.

      Field 1     03 apr 2017

      Field 2     28 Mar 2017 - Matches Field 1 ... - 6

      Field 3     29 Mar 2017 - Matches Field 1  ... - 5

      Field 4     30 Mar 2017 - Matches Field 1  ... - 4

      Field 5     31 Mar 2017 - Matches Field 1  ... - 3

      Field 6     01 Apr 2017 - Matches Field 1  ... - 2

      Field 7     02 Apr 2017 - Matches Field 1  ... - 1

      Field 8     03 Apr 2017 - Matches Field 1  ... - 0

       

      All has been working fine but i have just noticed that if i put the following into Field 1 "31 mar 2017" ... the following dates are auto-populated but skips 26 Mar 2017 - after 25 and before 27

      Field 1     31 mar 2017

      Field 2     24 Mar 2017 - Saturday

      Field 3     25 Mar 2017 - Sunday

      Field 4     27 Mar 2017 - Monday

      Field 5     28 Mar 2017 - Tuesday

      Field 6     29 Mar 2017 - Wednesday

      Field 7     30 Mar 2017 - Thursday

      Field 8     31 Mar 2017 - Friday

      The Javacript i am using is shown below

      Line 6 - the number in bold, is changed per cell

      i.e. FRIDAY

      var strStart = this.getField("DateStart").value;

      if(strStart.length)

      {

        var dateStart = util.scand("dd mmm yyyy",strStart);

        var oneDay = 24 * 60 * 60 * 1000;

        var dueMillis = dateStart.getTime() + -0 * oneDay;

        var dueDate = new Date(dueMillis);

        event.value = util.printd("dd mmm yyyy",dueDate);

      }

      else

        event.value = "NA";

       

      i.e. MONDAY

      var strStart = this.getField("DateStart").value;

      if(strStart.length)

      {

        var dateStart = util.scand("dd mmm yyyy",strStart);

        var oneDay = 24 * 60 * 60 * 1000;

        var dueMillis = dateStart.getTime() + -4 * oneDay;

        var dueDate = new Date(dueMillis);

        event.value = util.printd("dd mmm yyyy",dueDate);

      }

      else

        event.value = "NA";