Trying return a number on subtracting today's date from a given date in a field.
I have a date field ( date of a foreclosure sale) and are trying to add a calculation field show how many days are left to that auction sale date. Thanks
-
Hello Gunnar,
the general calculation for it is:
moment(@date field).diff(moment(),"days")
But: There' isn't a real "Today"-value available in the calculation field. Today's date is represented by: moment(). But It won't change. It fetches only the moment you saved the calculation or the moment a variable (in your case @date field) changes.
Means: If you create your field today (e.g.. June 15th) , it will have the right date But tomorrow (June, 16th) there will be the same (old) date. Only if the calculation is updated by a change in another variable in it (@date field) , it will change. For this issue see here https://help.podio.com/hc/communities/public/questions/204569657-Definite-solution-for-today-handling-in-calculated-fields-days-since-days-until-countdown-incl-possible-solution
There's only one workaround :
1. Create an app e.g. called "Timer" with a title field and a date field e.g. called "Today". Create one item only with the title e.g. "Today's date". In the date field enter the current date - you have to update this field every day. If you use Globiflow it can be done automatically, if not you have to do it manually (or via the API, which needs some developer skills).
2. Create a relationship field in the app where you want to calculate the difference (make it a "required field") which points to the app Timer and link each contact to the item "Today's date".Then you can use a calculation like
moment(@date field).diff(moment(@max of Today),"days")
For all of my Podio-clients I implement such a timer app. It's related to one or two central apps like Projects, Deliverables or employees/team member. These apps pull the today date into a calculation field (@max of today). Cause many other apps are related to one of central apps, all these apps have access to the today date and can use it for their calculations.
Rainer
rg@delos-consulting.com -
Hi Rachel,
21:00 shouldn't be possible,the date diff function always returns a number.
Check the settings of the calculation field if it is number or date type.
You can also create an new calc field, copy your code into it but add as last line 1. Save the template, open it again and remove the 1. This way you can be sure that it is number type.Rainer
Please sign in to leave a comment.
Comments
10 comments