Is there a formula for upcoming date using formula in Google sheet based on condition?

Viewed 173
2 Answers

This behavior (the next date from today including today) could be implemented manually by this formula:

={
  "Next date from today";
  ARRAYFORMULA(
    IFS(
      A2:A >= TODAY(),
        A2:A,
      B2:B = "Daily",
        TODAY() + MOD(TODAY() - A2:A, C2:C),
      B2:B = "Weekly",
        TODAY() + MOD(TODAY() - A2:A, 7 * C2:C),
      B2:B = "Monthly",
        EDATE(A2:A, ROUNDUP((12 * (YEAR(TODAY()) - YEAR(A2:A)) + (MONTH(TODAY()) - MONTH(A2:A)) - IF(DAY(TODAY()) < DAY(A2:A), 1, 0)) / C2:C, 0) * C2:C),
      True,
        ""
    )
  )
}

For additional options (like "every 2nd monday of the month" and others) additional options should be implemented in that IFS part.

enter image description here

If you are interested in a trivial case where the next date from the start date (column F:F on the screenshot) is needed, then the formula would be much simpler:

={
  "Next date";
  ARRAYFORMULA(
    IFS(
      B2:B = "Daily",
        A2:A + C2:C,
      B2:B = "Weekly",
        A2:A + 7 * C2:C,
      B2:B = "Monthly",
        EDATE(A2:A, C2:C),
      True,
        ""
    )
  )
}

Again, for additional options you'll need to add corresponding part to the IFS.

You could use IFS to check Frequency, and:

  • If Daily, add Count value to start date.
  • If Weekly, add Count value multiplied by 7.
  • If Monthly, since not all months have the same duration, retrieve the YEAR, MONTH and DAY indexes, add Count to the MONTH index, and set a new DATE, EDIT: or as suggested by kishkin, use EDATE.

It could be something like this:

=ARRAYFORMULA(IFNA(IFS(
    B2:B = "Daily", A2:A + C2:C,
    B2:B = "Weekly", A2:A + 7 * C2:C,
    B2:B = "Monthly", EDATE(A2:A,C2:C)
)))

enter image description here

Related