Add Days to Date in Pair of Date Components

I am experimenting with a pair of date components (the second could be just text).

I want to make the second read only (done) and display a date that adds x days to that date based on a rule, which will be calculated in a query. I'm not experienced in JavaScript and struggling with the syntax.

From the Community I found this code;

{ moment(new Date(), "DD-MM-YYYY").add(7, 'days')}}

When I put that in the Default value it successfully adds 7 days to today's date.

I want to use {{date1.value}} rather than todays date, what should the new code look like, what do I replace?

I am also assuming that when I use the query result I just replace the 7, i.e.

.add(7, 'days')}} ---> .add({{query.value}}, 'days')}}

Thanks in advance.

Hi, welcome to the community

Yep, you're almost there just need to trim down the number of {{ brackets you had in there.

Something like this:

{{ moment(date1.value).add(query.value, 'days') }}

example ->
forum.json (6.2 KB)


Thank you Dave!

Really appreciate the code pointer and especially the really useful json example. :slight_smile:

1 Like