Help

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

Topic Labels: Formulas
Solved
Jump to Solution
1247 6
cancel
Showing results for 
Search instead for 
Did you mean: 
Nick_Robeson
6 - Interface Innovator
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).

Screen Shot 2022-08-26 at 2.18.38 PM

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!

Thank you in advance!

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
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(
        DATEADD({Asset Launch Date}, 1, 'day'),
        "M/D/YY"
    ) & ", "
  ),
  IF(
    DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 2,
    DATETIME_FORMAT(
        DATEADD({Asset Launch Date}, 2, 'day'),
        "M/D/YY"
    ) & ", "
  ),
  IF(
    DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 3,
    DATETIME_FORMAT(
        DATEADD({Asset Launch Date}, 3, 'day'),
        "M/D/YY"
    ) & ", "
  ),
  IF(
    DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 4,
    DATETIME_FORMAT(
        DATEADD({Asset Launch Date}, 4, 'day'),
        "M/D/YY"
    ) & ", "
  ),
  IF(
    DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 5,
    DATETIME_FORMAT(
        DATEADD({Asset Launch Date}, 5, 'day'),
        "M/D/YY"
    ) & ", "
  )
), ", $", "")

See Solution in Thread

6 Replies 6
kuovonne
18 - Pluto
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(
        DATEADD({Asset Launch Date}, 1, 'day'),
        "M/D/YY"
    ) & ", "
  ),
  IF(
    DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 2,
    DATETIME_FORMAT(
        DATEADD({Asset Launch Date}, 2, 'day'),
        "M/D/YY"
    ) & ", "
  ),
  IF(
    DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 3,
    DATETIME_FORMAT(
        DATEADD({Asset Launch Date}, 3, 'day'),
        "M/D/YY"
    ) & ", "
  ),
  IF(
    DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 4,
    DATETIME_FORMAT(
        DATEADD({Asset Launch Date}, 4, 'day'),
        "M/D/YY"
    ) & ", "
  ),
  IF(
    DATETIME_DIFF({Asset End Date}, {Asset Launch Date}, 'days') >= 5,
    DATETIME_FORMAT(
        DATEADD({Asset Launch Date}, 5, 'day'),
        "M/D/YY"
    ) & ", "
  )
), ", $", "")

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.

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

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

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!

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.