# Formula listing ALL dates between between {Start Date} field & {End Date} field

Topic Labels: Formulas
Solved
2591 8
cancel
Showing results for
Did you mean:
6 - Interface Innovator

Hi all,

Hoping someone can help with a solution! My company has numerous assets that are “active” for long periods of time. I have a formula to calculate the “Active Status” based on the Asset Launch Date & Asset End Date (see below for reference).

I would like to make an additional field that lists ALL dates an asset is going to be active based on the start and end dates (placeholder included in the image above). For example, if Asset Launch Date = 9/1/22 & Asset End Date = 9/5/22, I’d like the ALL ACTIVE DATES field to read: “9/1/22, 9/2/22, 9/3/22, 9/4/22, 9/5/22”

Note: This field would be hidden 99.9% of the time and ONLY used in an Interface Filter element to allow users to type in specific dates (i.e. 9/3/22) and see the assets that will be “Active” on that date.

If there is another solution you can think of, feel free to leave it here as well!

1 Solution

Accepted Solutions
18 - Pluto

If you want to do this with a formula field, there is a limit to the number of possible dates.

This formula gives you starting point. You can extend it as needed, but as you can see, it can only handle a set maximum number of dates.

``````REGEX_REPLACE(CONCATENATE(
DATETIME_FORMAT(
{Asset Launch Date},
"M/D/YY"
) & ", ",
IF(
DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 1,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 2,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 3,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 4,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 5,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
)
), ", \$", "")
``````
8 Replies 8
18 - Pluto

If you want to do this with a formula field, there is a limit to the number of possible dates.

This formula gives you starting point. You can extend it as needed, but as you can see, it can only handle a set maximum number of dates.

``````REGEX_REPLACE(CONCATENATE(
DATETIME_FORMAT(
{Asset Launch Date},
"M/D/YY"
) & ", ",
IF(
DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 1,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 2,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 3,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 4,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 5,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
)
), ", \$", "")
``````
18 - Pluto

You could have filter conditions based on “is after” the launch date and “is before” the end date. The user would have to enter dates in both filter conditions, but it is also allows for more flexible searching.

6 - Interface Innovator

This is exactly what I was looking for! I really appreciate your help and everything you do for the Airtable community!

6 - Interface Innovator

Tried implementing this (as well as a timeline view), but the individuals who wanted the functionality thought it was “too much work” :joy:

5 - Automation Enthusiast

I came across this looking for something similar.  I am using Airtable to schedule people for different assignments over a period of 4 months.  Some people might have the same assignment for the whole time, others will receive many shorter assignments.  I am creating an interface for the person who does the scheduling, and want her to be able to use a filter to search for "all people who are unassigned" on a particular day.  It seems to me that I would need to use the formula you shared @kuovonne, do a rollup so that all the dates for all assignments would show in one field, and then use the filter in the interface to search for anybody who does not have a particular date in their rollup.

How far can I stretch that formula you shared - meaning how many days can I use it for?

Do you see a better way to achieve what I am  trying to do?

Thank you!

18 - Pluto

I do not think that this formula will work for your use case. As you can see, each additional day requires seven more lines to the formula, so if someone has a single assignment for four months, the formula would need over 840 lines. Even if you could have such a monstrous formula, you would need to do a filtered search for where the formula result does not include the string for the desired date, and the date would need to be typed exactly. And that would only tell you if the person was available that single day, not other days for which the assignment lasts.

In general, Airtable does not handle looking for "unassigned" time slots well without scripting.

5 - Automation Enthusiast

Hello! Would it be possible to create a calendar based on those fields in between? We are trying to a time and attendance and would like to see who is off on certain days. Thank you!

4 - Data Explorer

Brilliant @kuovonne - thank you for doing the leg work.

For anyone else looking for an extension of this formula that would cover a typical vacation of up to 24 days here's the expansion, using fields simply named Start and End:

``````REGEX_REPLACE(CONCATENATE(
DATETIME_FORMAT(
Start,
"M/D/YY"
) & ", ",
IF(
DATETIME_DIFF(End, Start, 'days') >= 1,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 2,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 3,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 4,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 5,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 6,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 7,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 8,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 9,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 10,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 11,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 12,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 13,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 14,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 15,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 16,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 17,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 18,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 19,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 20,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 21,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 22,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 23,
DATETIME_FORMAT(
"M/D/YY"
) & ", "
),
IF(
DATETIME_DIFF(End, Start, 'days') >= 24,
DATETIME_FORMAT(