Adding days to a date field to calculate a future date

Comments

4 comments

  • -1
    Comment actions Permalink
  • Matt Angell

    Sara Høeg Højlund-Rasmussen, the link above does not exist, did it move?  And if so, could you please point me to the new link?

    Thank you!

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hey Matt,
    I think there are many expamples in this community. The code is: 

    var date = @Date field;
    var daysToAdd = 10;
    moment(date).add(daysToAdd,"days").toDate()

    That returns the result as a date (= calculation field looks like a date field).
    If you want it as text:

    moment(date).add(daysToAdd,"days").tz("America/New_York").format("MM/DD/YYYY")

    returns e.g.: 10/20/2021
    .tz() defines the timezone for the calculated date (in my example it's Eastern Time). If you want it in your timezone you can use the same one as in your personale Podio settings.  
    More about how to handle dates in Podio with the integrated date js.library "moment": https://momentjs.com/docs/

    Rainer

    1
    Comment actions Permalink
  • Maya

    Hey Rainer Grabowski

    I used the above code 

    But the problem I am facing is when I hard code a number i get the required result. 

    Here the vendor invoice receipt date  = 01/03/2023

    and when I use a variable I dont get the correct result

    I have used new calculation fields multiple time

    I have also made sure the variable is  numeric

    please see image

     

     

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk