Priya Martin
Priya Martin

Reputation: 1

How can I get Notion formula to calculate number of days between either now and a date or between 2 dates in an if statement?

I am trying to use the Formula field in Notion databases to calculate how many days have elapsed since a particular start date (if there is no end date yet) OR the number of days between the start and the end date (if both are provided.

I am using the formula below:

if(
    prop("Date End") == "", 
    dateBetween(now(), prop("Date Start"), "days"),
    dateBetween(prop("Date End"), prop("Date Start"), "days")
)

I get a correct result only when when both fields (Date Start & Date End) have a date in them

However, when either of the fields are empty, I do not get any result.

In the current scenario, I'm trying to get into the if-then part of the if statement (eg. Date Start = March 15, 2024 and Date End is empty) and somehow it's not working and the formula field (Days Elapsed) stays blank.

Please can someone help?

Thanks.

I get a correct result only when when both fields (Date Start & Date End) have a date in them

However, when either of the fields are empty, I do not get any result.

In the current scenario, I'm trying to get into the if-then part of the if statement (eg. Date Start = March 15, 2024 and Date End is empty) and somehow it's not working and the formula field (Days Elapsed) stays blank.

Upvotes: 0

Views: 436

Answers (0)

Related Questions