Get help from other Notion users

It's free & easy

Receive points, vote and give the solution

1vote

# Need help writing a multi-property if statement

I'm trying to build 3 formula's in Notion that does the following:

• Check multiple date properties within the same database for the earliest date, then set the entry in that column to the earliest date.
• Check multiple date properties within the same database for the latest date, then set the entry in that column to the latest date.
• Count the days between the earliest date and the latest date, and return a total number of days.

I've created this formula, and it works between the two properties.

``if(prop("DateA") < prop("DateB"), prop("DateA"), prop("DateB"))``

But I need to index 5 different date properties, and choose the earliest one:
I've tried this, and it doesn't work:

``````if((prop("DateA") < prop("DateB")), prop("DateA"), prop("DateB"), if((prop("DateB") < prop("DateC")), prop("DateB"), prop("DateC"), if((prop("DateC") < prop("DateD")), prop("DateC"), prop("DateD"),
fromTimestamp(toNumber(""))))``````

Any help or guidance writing these formulas would be greatly appreciated!

1vote

LamboNr5 Points890

I build a solution for you:

The formulars are:

Earliest Date:

``fromTimestamp(min(timestamp(prop("Date1")), timestamp(prop("Date2")), timestamp(prop("Date3")), timestamp(prop("Date4")), timestamp(prop("Date5"))))``

Latest Date:

``fromTimestamp(max(timestamp(prop("Date1")), timestamp(prop("Date2")), timestamp(prop("Date3")), timestamp(prop("Date4")), timestamp(prop("Date5"))))``

Difference:

``````dateBetween(end(prop("Latest Date")), start(prop("Earliest Date")), "days")
``````

Note that every date has to be filled in order to work properly.

Hope that I could help.