How do I...?

Using application script, add days to a date that was set in a form

Users set "First Day" creating a new record.
I have it in my script: def fday = currentValues["First Day"]
Than I want to add for example 30 days and save this new date in a date field. (using script)

0 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Anonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    2 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Witte commented  ·   ·  Flag as inappropriate

        Hello,

        To add 30 days to your date with application scripts, you first need to create a variable with the original date, like this:

        Date newDate = currentValues["First Day"] as Date

        Next, you can update the variable by adding 30. If you add an integer to a date, application scripts will always treat that integer as a number of days (as opposed to hours, months, etc).:

        newDate = newDate + 30

        Finally, save the updated variable into the new date field.:

        currentValues["New Date"] = newDate as Date

        I hope this is helpful. If you have any additional questions on this, feel free to contact our support team directly at support@trackvia.com.

        Regards,

        Witte

      Feedback and Knowledge Base