Skip to main content
Solved

Airtable Date Calculation

  • April 25, 2023
  • 2 replies
  • 44 views

Forum|alt.badge.img+3

Hi everyone!

I am currently setting up a database to calculate how long a project has been active.

This means I'd like a formula that calculates the difference between (a) the start and finish dates or (b) the start and current date (if a finish date has not been specified).

I know of formulas that can do either of the needed functions, but not one that is conditional and selects which calculation is appropriate for each project. 

Hopefully someone might be able to help me out? 

Thanks again!

Best answer by Alexey_Gusev

Hi.
Airtable formulas are quite flexible. Statement 'if value X exists, show X, otherwise show Y' will be IF(X,X,Y)
You can even omit 'value if false', the default is 'show nothing' : if(X,X)
in you case, to get simple date difference, formula is:

 

DATETIME_DIFF({End Date},{Start date},'days')

 

if you want to use current date when end date is empty, it might be:

 

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

 



2 replies

Alexey_Gusev
Forum|alt.badge.img+25
  • Brainy
  • Answer
  • April 25, 2023

Hi.
Airtable formulas are quite flexible. Statement 'if value X exists, show X, otherwise show Y' will be IF(X,X,Y)
You can even omit 'value if false', the default is 'show nothing' : if(X,X)
in you case, to get simple date difference, formula is:

 

DATETIME_DIFF({End Date},{Start date},'days')

 

if you want to use current date when end date is empty, it might be:

 

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

 




Forum|alt.badge.img+3
  • Author
  • New Participant
  • April 29, 2023

Hi.
Airtable formulas are quite flexible. Statement 'if value X exists, show X, otherwise show Y' will be IF(X,X,Y)
You can even omit 'value if false', the default is 'show nothing' : if(X,X)
in you case, to get simple date difference, formula is:

 

DATETIME_DIFF({End Date},{Start date},'days')

 

if you want to use current date when end date is empty, it might be:

 

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

 




Hi Alexey,

Awesome, thanks so much for your assistance - it worked!