Formula for calculating age with an IF

#1

What is the formula for calculating age if someone is checked off as a child.
Thank you!

0 Likes

#2

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

0 Likes

#3

image
My field is named DOB but I get this error message.

0 Likes

#4

I wish I could help more. I got the formula from a table I am already using. I believe from what someone else taught me on here is if the field date is already named you do not need the brackets. So try this…
DATETIME_DIFF(TODAY(), DOB,‘years’)

0 Likes

#5

@Terri_Bose, the problem is with your quotation marks. If you notice, the quotation marks you have around the word years are slanted - these are a special type of unicode character called “smart quotes”, and they are not compatible with Airtable’s formula editor.

Copy and paste this version into your formula editor:

DATETIME_DIFF(TODAY(), {DOB}, 'years')

The quotation marks there are straight up and down, called “dumb quotes”. It’s a finicky thing, but Airtable’s formula editor only accepts dumb quotes. When you copy text for a formula from the forums here, if that text is not inside a code block (as mine is above), then you will likely end up copying “smart quotes” out of it. You just have to be careful and keep an eye on those when you are pasting it into Airtable’s formula editor.

@Holli_Younger – FWIW, you can create a code block using three “back-tick” characters (```) and then hitting enter, typing your formula, hitting enter, and closing it with three more “back-ticks”. The back-tick is on the same key as the tilde (~) character. This makes the formatting of formulas look nicer and more readable, and it automatically converts quotation marks typed in into “dumb quotes” so that people can copy-paste from the forums into Airtable. :slight_smile:

1 Like

#6

Also, @Terri_Bose, it seems your original question is still unanswered… you are wanting to conditionally check the age, whereas that formula always checks the age.

Assuming (based on your wording) that you have a checkbox field called “Child”, which will be checked if the record refers to a child, and therefore the age needs to be calculated, here is what you’d want:

IF(
   {Child},
   DATETIME_DIFF(
      TODAY(),
      {DOB},
      'years'
   )
)
0 Likes

#7

Thank you! This helps a lot!

1 Like

#8

I was having a problem with my own formula on something else and this solved my problem! :slight_smile:

1 Like

#9

Perfect! Thanks so much!

1 Like