Notion Answers

Get help from other Notion users


Register & Ask

It's free & easy

Get answers

Answers, votes & comments

Vote and select answers

Receive points, vote and give the solution

Question

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!

1 Answer

1vote

LamboNr5 Points890

Hi @goosetown47

I build a solution for you:
https://jan-lambers.notion.site/Date-comparison-cad77328c0fb46d2b637c882497087b0

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.

Please log in or register to answer this question.

Exclusive for Notion Answers Users

...

Welcome to Notion Answers, where you can ask questions and receive answers from other members of the community.

Please share to grow the Notion Community!

Connect