Help

Formula for calculating age with an IF

1965 8
cancel
Showing results for 
Search instead for 
Did you mean: 
Terri_Bose
6 - Interface Innovator
6 - Interface Innovator

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

8 Replies 8
Holli_Younger
8 - Airtable Astronomer
8 - Airtable Astronomer

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

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

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’)

@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. :slightly_smiling_face:

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'
   )
)

Thank you! This helps a lot!

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

Perfect! Thanks so much!