Expand my Community achievements bar.

SOLVED

Offsetting Date in Second Date Field (LiveCycle)

Avatar

Level 1

Hi, I am currently designing a form and in a particular section I have enabled the user to select the current month using a date picker (Date/Time Field) where a second Date/Time Field will automatically fill.

I have set the Data Connection to global (so they are connected), however I wish to offset the date in the second date field by nine months, where April 2018 will appear as January 2019, May 2018 as February 2019, and so on.

Please let me know how I may be able to do this.

Thanks,

Nate

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Nate,

I think you should remove the global binding and use a calculate event in the second date field, Something like this JavaScript

if (!DateField1.isNull) {

    var date = util.scand("yyyy-mm-dd", DateField1.rawValue);

    if (date != null) {

        date.setMonth(date.getMonth() + 9);

        util.printd("yyyy-mm-dd", date);

    }

}

You should just need to change the name of the first date field from the DateField1 name I have used in the above sample.

Bruce

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi Nate,

I think you should remove the global binding and use a calculate event in the second date field, Something like this JavaScript

if (!DateField1.isNull) {

    var date = util.scand("yyyy-mm-dd", DateField1.rawValue);

    if (date != null) {

        date.setMonth(date.getMonth() + 9);

        util.printd("yyyy-mm-dd", date);

    }

}

You should just need to change the name of the first date field from the DateField1 name I have used in the above sample.

Bruce

Avatar

Level 1

Hi Bruce,

Thank you for the prompt reply.

I was able to implement the above script in LiveCycle and it works exactly as required.

I greatly appreciate your help and once again, thank you.

Regards,

Nate