Find Lowest Date From Multi Fields
AnsweredHi
I have an Apps "Documents" and it contain Multi type document Expiry Date. Passport, ID, Licenses, OtherPass etc.
Now i just want to add a calculation field and Get Upcoming Expiry Date from those DateFields.
Thanks in Advance
-
Hi,
do you want a calculation like: if expiry date = today show "Expired" ? If so that's not possible. see here: https://help.podio.com/hc/communities/public/questions/202577457-Determine-if-a-deliverable-is-overdue-and-display-Overdue-if-it-is-?_ga=1.164409081.716129646.1431329936
Or are you asking for another use case?
Rainer
-
Ah ok, didn't get it that these are all date fields. sorry.
I'm sure there would be a more elegant way, but this works:dat1 = moment(@date 1).format("YYYY-MM-DD"); dat2 = moment(@date 2).format("YYYY-MM-DD") dat3 = moment(@date 3).format("YYYY-MM-DD"); dat4 = moment(@date 4).format("YYYY-MM-DD"); var arr = [dat1,dat2,dat3,dat4] var arr1 = arr.sort().join().split(",") moment(arr1[0]).toDate()
Instead of @date 1 etc. enter your date fields. The result is a date in date format which can be shown in a calendar. This formula is for calculating the dates in the same item.
Rainer
rg@delos-consutling.com -
Hi Dan,
just add .reverse() after .sort() to get the "youngest" (= max) date
dat1 = moment(@Date 1).format("YYYY-MM-DD");
dat2 = moment(@Date 2).format("YYYY-MM-DD");
dat3 = moment(@Date 3).format("YYYY-MM-DD");
var arr = [dat1,dat2,dat3].filter(function (i) { return i != "Invalid date"; }).sort().reverse();
arr.length == 0 ? "" : moment(arr[0]).toDate()The filter function removes date fields which are empty.
Rainer
Please sign in to leave a comment.
Comments
11 comments