Skip to main content
Solved

Struggling with a formula for counting difference between dates

  • Aug 19, 2019 2:48 PM UTC
  • 3 replies
  • 95 views

Hello,

I’m trying to make a formula that counts the difference between start date and end date, however if end date is blank calculate the difference between start date, and current date.

Sorry if it sounds simple, i’m very new to airtable!

Thanks
Matt

Best answer by JonathanBowen

Hi @Matthew_Grundy - try this:

IF(
{End Date}, 
DATETIME_DIFF({End Date}, {Start Date}, 'days'), 
DATETIME_DIFF(TODAY(), {Start Date}, 'days')
) 

JB

View original
This topic has been closed for replies.

3 replies

JonathanBowen
Forum|alt.badge.img+18
  • Inspiring
  • Answer
  • Aug 19, 2019 3:29 PM UTC

Hi @Matthew_Grundy - try this:

IF(
{End Date}, 
DATETIME_DIFF({End Date}, {Start Date}, 'days'), 
DATETIME_DIFF(TODAY(), {Start Date}, 'days')
) 

JB


Justin_Barrett
Forum|alt.badge.img+21

Hi @Matthew_Grundy - try this:

IF(
{End Date}, 
DATETIME_DIFF({End Date}, {Start Date}, 'days'), 
DATETIME_DIFF(TODAY(), {Start Date}, 'days')
) 

JB


Here’s another way to write it, putting the IF function inside a single DATETIME_DIFF:

DATETIME_DIFF(IF({End Date}, {End Date}, TODAY()), {Start Date}, "days")

  • Author
  • New Participant
  • Aug 20, 2019 8:48 AM UTC

Hi @Matthew_Grundy - try this:

IF(
{End Date}, 
DATETIME_DIFF({End Date}, {Start Date}, 'days'), 
DATETIME_DIFF(TODAY(), {Start Date}, 'days')
) 

JB


Works perfectly!
thank you for your help.

Matt