Skip to main content

[Solved] DATEADD error when using IF({name}=BLANK(),'',


Forum|alt.badge.img+3

Hi all!
I’m relatively new to anything beyond simple in Airtable, but I’m learning through trial and error.
I’ve ran into a problem I can’t solve though (yet) and would greatly appreciate any and all help.

When using the following formula i end up getting error messages.

IF(
{Kontroll intervall}="Varje vecka",
DATEADD({Senast kontrollerad}, '7', 'days'),
	IF({Kontroll intervall}="Varannan vecka",
	DATEADD({Senast kontrollerad}, '14', 'Days'),
		IF({Kontroll intervall}="En gång i månaden",
		DATEADD({Senast kontrollerad}, '30', 'Days'),
			IF({Kontroll intervall}="Varannan månad",
			DATEADD({Senast kontrollerad}, '60', 'Days'),
				IF({Kontroll intervall}="En gång per kvartal",
				DATEADD({Senast kontrollerad}, '120', 'Days'),
					IF({Kontroll intervall}="Ombyggnad, ej aktuell i nuläget",
					DATEADD({Senast kontrollerad}, '60', 'Days'),
						IF({Kontroll intervall}="Ej evenemangshemsida",
						DATEADD({Senast kontrollerad}, '365', 'Days'),
							IF({Kontroll intervall}="Behövs inte kollas av",
							DATEADD({Senast kontrollerad}, '365', 'Days')))))))))

As seen here

So I tried altering as follows

IF(
{Senast kontrollerad}=BLANK(),
'',	
IF({Kontroll intervall}="Varje vecka",
DATEADD({Senast kontrollerad}, '7', 'days'),
	IF({Kontroll intervall}="Varannan vecka",
	DATEADD({Senast kontrollerad}, '14', 'Days'),
		IF({Kontroll intervall}="En gång i månaden",
		DATEADD({Senast kontrollerad}, '30', 'Days'),
			IF({Kontroll intervall}="Varannan månad",
			DATEADD({Senast kontrollerad}, '60', 'Days'),
				IF({Kontroll intervall}="En gång per kvartal",
				DATEADD({Senast kontrollerad}, '120', 'Days'),
					IF({Kontroll intervall}="Ombyggnad, ej aktuell i nuläget",
					DATEADD({Senast kontrollerad}, '60', 'Days'),
						IF({Kontroll intervall}="Ej evenemangshemsida",
						DATEADD({Senast kontrollerad}, '365', 'Days'),
							IF({Kontroll intervall}="Behövs inte kollas av",
							DATEADD({Senast kontrollerad}, '365', 'Days'))))))))))	

with following result

My questions are as follows:

  1. How do I fix the second formula so that the date displays correctly?
  2. For learning purposes - Why does it give the odd addition to the date with the second formula?

3 replies

Forum|alt.badge.img+18
IF(
   {Senast kontrollerad},
   SWITCH(
      {Kontroll intervall},
      "Varje vecka", DATEADD({Senast kontrollerad}, 7, 'days'),
      "Varannan vecka", DATEADD({Senast kontrollerad}, 14, 'days'),
      etc... following the pattern
   )
)

make sure your final DATEADD() statement does NOT have a comma after it - just the closing parenthesis

Instead of checking for blank cells and proactively filling this one with an empty string, it’s better to check for the presence of a value in the date field, and only evaluate the rest of the IF() statement if there is a value in it.

The SWITCH() statement can replace a nested IF() statement if you are repeatedly checking the value of the same field over and over, and asking for the evaluation of a different function depending on its value.

The reason your second attempt returned ISO formatted dates is because Airtable recognized that your formula could evaluate to one of TWO data-types - if your date field is blank, you were telling it to evaluate to an empty string - ‘’ -but an empty string is still a string, which is a particular data-type, and is different from a date data-type. To resolve this, Airtable was formatting your dates as strings (the least common denominator data-type) and not allowing you to choose it’s date-output format.

Airtable only allows you to choose a date data-type output format if your formula is only able to return a date. The method I shared still checks for a date in your date field first, to avoid the ERROR#, but instead of returning an empty string when it’s blank, it simply does nothing - this leaves the cell in a state called “null”. It means “this field is reserved to hold a specific data-type (in this case, a date), but currently has no value.”

null =/= ‘’ =/= ERROR#


Forum|alt.badge.img+3
  • Author
  • Known Participant
  • 43 replies
  • January 12, 2019
Jeremy_Oglesby wrote:
IF(
   {Senast kontrollerad},
   SWITCH(
      {Kontroll intervall},
      "Varje vecka", DATEADD({Senast kontrollerad}, 7, 'days'),
      "Varannan vecka", DATEADD({Senast kontrollerad}, 14, 'days'),
      etc... following the pattern
   )
)

make sure your final DATEADD() statement does NOT have a comma after it - just the closing parenthesis

Instead of checking for blank cells and proactively filling this one with an empty string, it’s better to check for the presence of a value in the date field, and only evaluate the rest of the IF() statement if there is a value in it.

The SWITCH() statement can replace a nested IF() statement if you are repeatedly checking the value of the same field over and over, and asking for the evaluation of a different function depending on its value.

The reason your second attempt returned ISO formatted dates is because Airtable recognized that your formula could evaluate to one of TWO data-types - if your date field is blank, you were telling it to evaluate to an empty string - ‘’ -but an empty string is still a string, which is a particular data-type, and is different from a date data-type. To resolve this, Airtable was formatting your dates as strings (the least common denominator data-type) and not allowing you to choose it’s date-output format.

Airtable only allows you to choose a date data-type output format if your formula is only able to return a date. The method I shared still checks for a date in your date field first, to avoid the ERROR#, but instead of returning an empty string when it’s blank, it simply does nothing - this leaves the cell in a state called “null”. It means “this field is reserved to hold a specific data-type (in this case, a date), but currently has no value.”

null =/= ‘’ =/= ERROR#


Thank you so much for your help and extra so for taking the time to explain it all.
That worked perfectly.


Forum|alt.badge.img+1
  • New Participant
  • 1 reply
  • March 29, 2025

Hi Annica! The issue in your second formula is that you're mixing data types by returning an empty string '' for blank dates while returning date objects in other cases. Airtable gets confused when trying to display this mixed format. Here are two solutions:

  1. For blank dates, return a true blank (null) instead of empty string:

Copy

IF(  {Senast kontrollerad}=BLANK(),  BLANK(),  /* rest of your formula */)
  1. Alternative - use DATETIME_FORMAT to ensure consistent output:

Copy

IF(  {Senast kontrollerad}=BLANK(),  '',  DATETIME_FORMAT(    /* your entire DATEADD logic here */,    'YYYY-MM-DD'  ))

The odd date display happens because Airtable tries to interpret your empty string as a date when other results in the field are dates. Stick to either all dates or all strings for consistent results.

Great job troubleshooting this! The nested IF structure itself looks solid.

PaybyPlateMa

Reply