Skip to main content

Days between dates

  • March 21, 2016
  • 22 replies
  • 129 views

Can anyone tell me the formula for calculating the number of days between “date logged” and “date completed”. And if the formula could be expressed as working weekdays only that would be icing on the cake! Many thanks

22 replies

  • Known Participant
  • 22 replies
  • March 23, 2016

  • Author
  • New Participant
  • 2 replies
  • March 24, 2016

Exactly what I needed. Thanks Martha


  • New Participant
  • 1 reply
  • May 11, 2016

Hi Max - wouldn’t that be DATETIME_DIFF?
See https://support.airtable.com/hc/en-us/articles/203255215-Formula-field-reference#date_and_time_functions


Is the second part of the original query possible – to calculate the number of weekdays via DATETIME_DIFF or another formula?


  • Known Participant
  • 22 replies
  • May 16, 2016

Is the second part of the original query possible – to calculate the number of weekdays via DATETIME_DIFF or another formula?


Hi Mike -
Probably you can get that with more elaborate calculations, but I haven’t tried to work that out. I don’t see that Airtable yet has the functionality that Excel provides with NETWORKDAYS.
Martha


  • Participating Frequently
  • 8 replies
  • July 14, 2016

Old thread; but hey the topic still has merit

I tried this formula DATETIME_DIFF([date1], [date2], ‘units’) and I get an error message so tried this:

DATETIME_DIFF([Date Depleted], [Date Purchased, ‘days’) and so I am assuming I am doing it incorrectly.


  • New Participant
  • 2 replies
  • March 7, 2017

I would love to see Business days added to the Supported unit specifiers for DATETIME_DIFF


Forum|alt.badge.img+5
  • Inspiring
  • 332 replies
  • August 30, 2017

Some of you in this thread might be happy to know that we’ve implemented a WORKDAY() function!

The format is WORKDAY(startDate, numDays, [holidays]) and it returns a date that is numDays working days after startDate. Working days automatically exclude weekends, and you can include an an optional list of holidays as a comma-separated string of ISO-formatted dates, e.g.

WORKDAY({Launch date}, 100, '2017-09-04, 2017-10-09, 2017-11-10')


  • New Participant
  • 2 replies
  • October 24, 2017

Some of you in this thread might be happy to know that we’ve implemented a WORKDAY() function!

The format is WORKDAY(startDate, numDays, [holidays]) and it returns a date that is numDays working days after startDate. Working days automatically exclude weekends, and you can include an an optional list of holidays as a comma-separated string of ISO-formatted dates, e.g.

WORKDAY({Launch date}, 100, '2017-09-04, 2017-10-09, 2017-11-10')


Excellent! Could we please have the inverse function as well (a function that will return the number of workdays/workhours between two date/time fields)?


  • New Participant
  • 1 reply
  • October 25, 2017

Does anyone know how to use the datetime_diff function with multiples dates in one cell that are then compared to one date? Example of the picture below.


  • New Participant
  • 2 replies
  • October 27, 2017

Does anyone know how to use the datetime_diff function with multiples dates in one cell that are then compared to one date? Example of the picture below.


You would need to run your datetime_diff function in the table where your Calls are located (using a lookup field for onboarding date if necessary). Then, you could bring the results to the current view with another lookup field in the same way you have brought in the Dates of Call IDs.


  • Participating Frequently
  • 5 replies
  • January 2, 2018

Excellent! Could we please have the inverse function as well (a function that will return the number of workdays/workhours between two date/time fields)?


We’ve also just added a WORKDAY_DIFF formula! Documentation here.

It takes in a start date, end date, and optional list of holidays, like so: WORKDAY_DIFF({Assignment date}, {Due Date}, '2017-09-04, 2017-10-09, 2017-11-10'), and returns the number of working days between the start date and end date, inclusive.

For those of you familiar with Excel or Sheets, it’s pretty much isomorphic to the NETWORKDAYS formula in those products.


  • New Participant
  • 3 replies
  • March 30, 2018

Old thread; but hey the topic still has merit

I tried this formula DATETIME_DIFF([date1], [date2], ‘units’) and I get an error message so tried this:

DATETIME_DIFF([Date Depleted], [Date Purchased, ‘days’) and so I am assuming I am doing it incorrectly.


I’m in the same boat. Here’s what I’m trying to run:
DATETIME_DIFF([Start date], [End date, ‘weeks’)

However, I’m still getting an error message.

So this leads me to two fundamental questions:

  • Can I deduce the difference between two fixed dates (or does it have to the number of days, weeks, etc. between a past date and the present)?

  • If so, how can I fix my formula?

Thanks!


Forum|alt.badge.img+5
  • Inspiring
  • 1386 replies
  • March 30, 2018

I’m in the same boat. Here’s what I’m trying to run:
DATETIME_DIFF([Start date], [End date, ‘weeks’)

However, I’m still getting an error message.

So this leads me to two fundamental questions:

  • Can I deduce the difference between two fixed dates (or does it have to the number of days, weeks, etc. between a past date and the present)?

  • If so, how can I fix my formula?

Thanks!


By

do you mean you aren’t allowed to save the field but instead see a message beginning, ‘Sorry, there was a problem saving this field’? Or do you mean you can save the field correctly, but when you try to run the formula by populating the fields, you get an #ERROR message – or a NaN error?


  • New Participant
  • 3 replies
  • March 30, 2018

By

do you mean you aren’t allowed to save the field but instead see a message beginning, ‘Sorry, there was a problem saving this field’? Or do you mean you can save the field correctly, but when you try to run the formula by populating the fields, you get an #ERROR message – or a NaN error?


That’s right, it says ‘Sorry, there was a problem saving this field’?


Forum|alt.badge.img+5
  • Inspiring
  • 1386 replies
  • March 30, 2018

That’s right, it says ‘Sorry, there was a problem saving this field’?


In that case, it’s because you’re using the wrong characters to enclose the field names. Give this a try:

DATETIME_DIFF({Date Depleted},{Date Purchased},'days')

  • New Participant
  • 3 replies
  • April 3, 2018

That’s exactly what I needed. Thanks very much, @W_Vann_Hall. You’re aces!


  • New Participant
  • 1 reply
  • October 15, 2018

There’s function WORKDAY_DIFF


  • New Participant
  • 3 replies
  • October 21, 2018

Thanks so much @Martha_Creedon !! I searched google for the same problem and your response really helped me out quickly.


  • New Participant
  • 2 replies
  • August 6, 2019

I am trying to get the numbers of days difference between a date cell and a formula cell using IF({Return Solved}=1, DATETIME_FORMAT(SET_TIMEZONE(NOW(), ‘New Zealand/Wellington’), ‘D/M/YYYY’))

I am trying to use DATETIME_DIFF({Date of Return}, {Date Resolved}, ‘days’) but it is not showing the correct amount of days?

Any ideas?


  • New Participant
  • 2 replies
  • August 6, 2019

I am trying to get the numbers of days difference between a date cell and a formula cell using IF({Return Solved}=1, DATETIME_FORMAT(SET_TIMEZONE(NOW(), ‘New Zealand/Wellington’), ‘D/M/YYYY’))

I am trying to use DATETIME_DIFF({Date of Return}, {Date Resolved}, ‘days’) but it is not showing the correct amount of days?

Any ideas?


I just tried WORKDAY_DIFF({Date of Return}, {Date Resolved}) and now it is showing negative days?


  • Participating Frequently
  • 8 replies
  • June 22, 2020

That’s exactly what I needed. Thanks very much, @W_Vann_Hall. You’re aces!


This formula is what I’m looking for. However, I may not have a date in the second field and currently it returns NaN if something is missing in the secondary field. Is there anything that could be added to leave the field blank if there is nothing in that field. In the example above it would be if the {Date Purchased} was blank then the output would be left blank.

Thanks!


Justin_Barrett
Forum|alt.badge.img+21
  • Inspiring
  • 4647 replies
  • June 23, 2020

This formula is what I’m looking for. However, I may not have a date in the second field and currently it returns NaN if something is missing in the secondary field. Is there anything that could be added to leave the field blank if there is nothing in that field. In the example above it would be if the {Date Purchased} was blank then the output would be left blank.

Thanks!


IF({Date Purchased}, DATETIME_DIFF({Date Depleted},{Date Purchased},'days'))