Jun 13, 2016 07:03 AM
DATETIME_DIFF([date1], [date2], ‘units’)
I saw this formula but how do I modify it to include my fields and a result in years for the units?
Jan 22, 2020 10:03 AM
@Khatia_Odzelashvili, your error is due to the quotation marks in your formula - they are curly quotes rather than straight quotes, because you copy-pasted them from styles text here in the forums.
Try just deleting those quotes and retyping them directly in the formula editor.
In case that isn’t clear:
Jan 22, 2020 10:18 AM
Jeremy, thank you, it worked! :smiling_face_with_halo: :pray:
Feb 26, 2021 06:19 PM
That formula works for me! But when I put it in there’s a field that says NaN…is there a way for the field to be empty even if the birthdate field isn’t filled in?
Jul 14, 2022 08:10 AM
What am I doing wrong - just trying to calculate age from the date of birth
Sep 28, 2022 10:54 AM
It looks like you’ve combined the two approaches. My original solution using the DATETIME_DIFF()
function is fine, but it’s useful to check and see if there’s data in the cell that contains the {Date of Birth}
too. The function would look like this:
IF({Date of Birth}, DATETIME_DIFF(TODAY(), {Date of Birth}, 'years'))
As others have said, watch out for curly quotes. Make sure you have the straight tick mark quotes in your formulas.
The other approach using TONOW()
works too (and didn’t exist when I did my original post), but it includes the word years
in the output which I don’t want. That formula would look like this:
TONOW({Date of Birth}, 'years')
Either approach works.