How do I return nothing when a field is empty as opposed to "#ERROR"?


#1

When my Birthday field is empty, how do I get Age to show nothing as opposed to “#ERROR”? Here is my formula at this point:

DATETIME_DIFF(TODAY(), {Birthday}, ‘years’)

Thanks for any help given.


#2

You can use the IF function:

IF({Birthday}, DATETIME_DIFF(TODAY(), {Birthday}, ‘years’))


#3

Thanks, but I get an “invalid formula” response with this.


#4

I just copied it from a test base where it’s working. I suspect the problem is the quote, you should understand the recommendation and try yourself and not only copy and paste.


#5

You should be able to copy-and-paste this version of the formula successfully. (Note the difference in the single quotes: The version Elias posted had been ‘pretty formatted’ into ‘inverted comma’ style opening and closing single quotes — which Airtable does not like. Instead, you need to use the ‘straight single quote’ found in the following version. Alternatively, you can do as Elias suggests and simply overwrite the curly quotes with the straight one found on your keyboard.)

IF({Birthday}, DATETIME_DIFF(TODAY(), {Birthday}, 'years'))

.__________

@Elias_Gomez_Sainz I learn something new every day. Although I regularly use abbreviated comparisons in IF() statements when testing for zero vs. non-zero — e.g., IF(FIND('.',SomeText),This,That), for some reason it hadn’t sunk in I could do the same thing with BLANK() vs. not-BLANK(). Until about 5 minutes ago, I would have written that formula as

IF(Birthday=BLANK(),BLANK(),DATETIME_DIFF(TODAY(),Birthday,'years'))

Thanks for helping me trim redundant code!


#6

@W_Vann_Hall and @Elias_Gomez_Sainz

That worked like a charm! Thanks to both of you guys for the help.