Calculations using dates
Hi, I have a very easy calculation using dates but I can't get the date to format correctly. I want to calculate a target renewal date based on a lease end date and subtracting the lead time from the lease end date to get the target renewal date. My calculation is returning a very large integer and not a date. Can someone please help me? Thanks.
-
Hi Michael,
1. Delete that calculation field (s. here https://help.podio.com/hc/en-us/articles/201019358-Calculations, the paragraph above the video)
2. Create a new calculation field and enter:
moment(@Lease End Date).subtract(@Lead Time, "days").toDate()
That shows the date like a date field, means: it looks like a real date field and you can see in calendars (for checking the field settings click the little triangle at the left hand side of the module).
If you want it as text e.g in the the format 09/07/2018:
moment(@Lease End Date).subtract(@Lead Time, "days").format("MM/DD/YYYY")
Rainer
-
@Michael
Calculation fields are sometimes very "sensible" when you create them. My recommendation:
Add a new calc field, enter @created on, pick the token, save the template. Now you can be sure that the calc field is date type.
Go back into the template, remove @created on and enter your code (it's correct). Now you should the right date.
@Dirk
If your field should show the result as a date you can't add anything (a prefix would make it a string).
The calendar entry name is the first filled field in the item (text or calculation). If your use case and app does it allow, you can add a calculation field at the top with a dynamic calculation, maybe with some IF clauses (if field deadline filled display Deadline + title field, if not name of another date field, or if current is 2 days before Deadline date show Deadline ... or whatever makes sense)
Rainer
Please sign in to leave a comment.
Comments
7 comments