Help

Upcoming database upgrades. to improve our reliability at 03:30 UTC on Feb. 25 / 7:30pm PT on Feb. 24. Some users may briefly experience slow load times or error messages. Learn more here

Value based on relation to date

Topic Labels: Formulas
Solved
Jump to Solution
232 3
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi!

I want a field to show one of three values (Active, Expires in a week or Expired) depending on if the field “Startdatum” is after today, within a week or before today. How do I solve this?

Thanks!

1 Solution

Accepted Solutions

You need three nested IF() statements: one to check if the date field is filled in, one to test if its expired, and another to differentiate between those expiring within a week or sometime in the future.

IF(
   {Startdatum},
   IF(
      {Startdatum} < TODAY(), 
      "Expired",
      IF(
         DATETIME_DIFF({Startdatum}, TODAY(), "days") <= 7, 
         "Expires in a week",
         "Active"
      )
   ),
   "No date"
)

See Solution in Thread

3 Replies 3

You need three nested IF() statements: one to check if the date field is filled in, one to test if its expired, and another to differentiate between those expiring within a week or sometime in the future.

IF(
   {Startdatum},
   IF(
      {Startdatum} < TODAY(), 
      "Expired",
      IF(
         DATETIME_DIFF({Startdatum}, TODAY(), "days") <= 7, 
         "Expires in a week",
         "Active"
      )
   ),
   "No date"
)

Worked like a charm! Thanks alot :grinning:

Hi again! Can I have it so it doesn’t say “#ERROR” when “Startdatum” is empty?