Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Calculate DateTimeField

Avatar

Level 2

How do you add days to a date field using JavaScript in LiveCycle Designer ES2? I have a field named DTFBeg that is a user-input field. I'd like to take this value, add 7 days to it, and display the new value in the field called DTFThru. Both the fields are on the Master Page of a flowable form. I've tried so many different JavaScript options from different samples I've found online, but nothing I've tried pulls a value anywhere close to what I'm looking for.

Thanks in advance to anyone who can help!

Caroline

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hi Caroline,

you have to use this script in the exit-event from the user input-date-field.

if(this.rawValue != null)

{

    var sDate = util.scand("yyyy-mm-dd", this.rawValue);

    //THE SEVEN IN THE END OF THE LINE YOU CAN CHANGE WHEN YOU WISH TO ADD MORE OR LESS DAYS

    var NewsDate = Number(sDate) + (24*60*60*1000*7);

    var nDate = util.printd("dd.mm.yyyy", new Date(NewsDate));

   //DatumsUhrzeitfeld2 --> YOUR TARGET FIELD --> PLEASE CHANGE THE NAME IN YOURS

    DatumsUhrzeitfeld2.rawValue = nDate;

}

I hope it's helpfull for you?

Kind regards

Mandy

View solution in original post

0 Replies

Avatar

Correct answer by
Level 5

Hi Caroline,

you have to use this script in the exit-event from the user input-date-field.

if(this.rawValue != null)

{

    var sDate = util.scand("yyyy-mm-dd", this.rawValue);

    //THE SEVEN IN THE END OF THE LINE YOU CAN CHANGE WHEN YOU WISH TO ADD MORE OR LESS DAYS

    var NewsDate = Number(sDate) + (24*60*60*1000*7);

    var nDate = util.printd("dd.mm.yyyy", new Date(NewsDate));

   //DatumsUhrzeitfeld2 --> YOUR TARGET FIELD --> PLEASE CHANGE THE NAME IN YOURS

    DatumsUhrzeitfeld2.rawValue = nDate;

}

I hope it's helpfull for you?

Kind regards

Mandy

Avatar

Level 2

Thank you SO much, Mandy. I've been teaching myself the JavaScripting and can usually figure things out myself, but I would have never come up with this! I do appreciate your help immensely!

I do have one slight problem that hopefully you can help me with. I put the date fields on my Master Page with the thought that they would display on all pages, but the fields are only populating on the first page. I've looked at the properties on both fields to see if there was something to do with pagination, but don't see anything that's causing them to reset. Any ideas?

Avatar

Level 5

Hi Caroline,

I'm happy that's work.

For the next question I think it's better to open a new discussion? Then another user can find the solution because the new discussion have another significant title.

I will answer soon.

Kind regards,

Mandy

Avatar

Level 2

Thanks Mandy. Your solution works great for my purpose as well.