Search code examples
jsonata

In JSONata How to print date from todays date+60 calendar days


For eg:

  • if today's date is 03/39/2024, it should print after 60 days -05/28/2024

Code to get today's date:

$fromMillis($toMillis($now()), '[M01]/[D01]/[Y0001]')

But how to print for 60 calendar days in jsonata? Can anyone please help?`


Solution

  • As suggested in Willy K.'s comment to your question, you can try the following expression:

    $fromMillis($toMillis($now()) + 60 * 86400000, '[M01]/[D01]/[Y0001]')

    There are 86400000 milliseconds in 24 hours (1 day) and multiplying that by 60 (days) should return a date that is 60 days into the future from the current date.

    Link to JSONata playground: https://jsonatastudio.com/playground/29f9abbe