Calculating a new date +/- X days
Hi
I want to calculate a new date (which I can then use in tasks, in workflow) based on an existing date.
For example:
- Due Date is 31/03/2014 (dd/mm/yyyy)
- I want to automatically set a new date which is 30 days earlier (which would be 01/03/2014)
- I then want to be able to create a task (using workflow) which sets the task due date as the 'new date' field.
The purpose of it is to remind one of our users that an article is due for publication 30 days before the due date.
Thanks
-
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'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 "
Please sign in to leave a comment.
Comments
7 comments