# Airtable Date Calculation

Topic Labels: Data Formulas
Solved
1156 2
cancel
Showing results for
Did you mean:
5 - Automation Enthusiast

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!

1 Solution

Accepted Solutions
12 - Earth

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 2
12 - Earth

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')``

5 - Automation Enthusiast

Hi Alexey,

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