Calculating a new date +/- X days

Comments

6 comments

  • Michael Kagan

    Hey everyone,

    This thread was most helpful to me (a non-programmer).

    I was trying to increment the date and Damir's code was most helpful. I finally got it to work for me with the following coding (after deleting the calculation field and creating a new one, thanks for that tip as well!):

    var zover = @Start Date
    zover.setDate(@Start Date.getDate() + @Duration);
    zover;

    1
    Comment actions Permalink
  • Justin VanDervort

    Michael Kagan's response below truly worked for me! I had to add one extra day for some reason, I'm not sure. But this added days to my date and returned a date that podio recognized as a date again!  Here's the exact script I used below with my references and then Michael's post quoted below that. 

    var zover = @Supplement Plan Start Date
    zover.setDate(@Supplement Plan Start Date.getDate() + @[Days of Supply] + 1);
    zover;

     

    Quote:

    "Hey everyone,

    This thread was most helpful to me (a non-programmer).

    I was trying to increment the date and Damir's code was most helpful. I finally got it to work for me with the following coding (after deleting the calculation field and creating a new one, thanks for that tip as well!):

    var zover = @Start Date
    zover.setDate(@Start Date.getDate() + @Duration);
    zover;

    Michael Kagan "
    1
    Comment actions Permalink
  • Damir Ayginin

    Hi, James.

    I've managed to do this yesterday with

    @Date.setDate(@Date.getDate() - 30);
    @Date;

    But, unfortunately, workflows don't recognize these date fields as the ones we can use as "due" :(

    0
    Comment actions Permalink
  • James Lawler

    Hi Damir,

    I tried your code but it didn't work.

    Do all 3 '@Date' references reference the same field? In my case 'Publication Date'

    0
    Comment actions Permalink
  • Damir Ayginin

    Yep, they do reference to the same @publication date.

    Have you tried deleting calculation field and creating a new one?

    0
    Comment actions Permalink
  • James Lawler

    That sorted it thanks!

    It's a shame you can't use the date within workflow due dates!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk