Calculating a date and formatting as a date
Hi Everyone
Hope this post is in the right place.
I am a complete novice but we use Podio to plan our budding projects, we have a milestone app which has fields for when certain things are due, i.e issue drawings 4 weeks before our site start date (which is a manually entered date).
I don't know Java Script at all but currently I am using the below which I found elsewhere on this forum a year so or ago:
moment(@Site Start).subtract('days', 28).format("dddd DD MMMM YYYY")
This works and shows the date, but I can't run any reports on it, i.e. all projects where this item is due in the next week or something, I think because it's outputting text.
Is there a similar line that will output it as a date so I can run reports, or is this too complicated for someone who doesn't know Java Script?
Thanks in advance
Craig
-
I'm having problems with the following:
moment(@Min of Event Date).subtract('days', @LeadTime).toDate()
@Min of Event Date is a static start date (date field)
@Lead time is variable for each action item (text field as whole number)
Formula is generating the same result for all action items, regardless of variable lead times: 12/31/1969 6:00 PM
Any idea what is causing the error?
Thanks! -
Hi Rainer. Can we do the opposite? Instead of subtracting can we add one day? On the code: moment(moment().format('YYYY') + '-' + moment(@Birthday).format('MM-DD')).toDate(); we get the anniversary date one day before the exact date, i.e. +365. How can we add one more day so the code returns the exact anniversary date? 22nd to 22nd, and not 22nd to 21st of March, as an example. Thanks as always.
-
Hi Gus,
Q: Can we do the opposite?
A: Yes, just do the opposite: .add(1,"day").toDate().
But I don't understand your code: moment(moment().format('YYYY') + '-' + moment(@Birthday).format('MM-DD')).toDate()
It shows you the date for the year you enter something in the field @birthday. But the year value will never change, it will always show 2017 (except you will change something directly in the calculation). moment() catches the moment you do something.
And what about leap years? You have to add 2 days.If your want to have a date field which always shows the next anniversary date you need another setup.
Rainer
-
Hi Rainier, hi All,
Thought I would piggy-back off this post as you made a relevant comment to my scenario.
I have an "agreements" app which holds all my agreements, either supplier or partner agreements.
In the app, I have a start date, (Date field) and a contract duration (number field).
I also have a calculation field which I would like to calculate the upcoming renewal date of the contract.So for example, if I have a contract starting 1.11.2017 with a duration of 12 months, I would like to calculation to return 1.11 so that each year the contract is active, I will see the date it is due.
2 questions:
1. How would I calculate the "due date" ie the day and month that a contract is up for renewal, given the data above?
2. How would I automatically create a task (for example 14 days before a contract is up) to renew, and an email alerting me of the deadline?Any help would be much appreciated!
Stuart
Please sign in to leave a comment.
Comments
8 comments