βApr 05, 2020 10:10 PM
Hi!
I have a formula that works awesomly to calculate international age (see below).
IF(
{π Birthday}=BLANK(),
' (N/A)',
IF(
{π Death}=BLANK(),
IF({π Birthday},' ('&DATETIME_DIFF(TODAY(), {π Birthday}, 'years')&')'),
IF({π Birthday},' (β '&DATETIME_DIFF({π Death}, {π Birthday}, 'years')&')')
)
)
{ :id: Birthday} is a date field.
Iβve been trying to adapt this formula to calculate Korean age.
I would need it to do something like
IF({π Birthday},IS_BEFORE(TODAY(),DATETIME_FORMAT({π Birthday}, 'MMDD'),+2 'years',+1 'Years'))
β¦if that makes sense? Iβve been banging my head for too long that even the above might have an error. So in plain English: if today is before a persons birthday (but after January 1) I want it to add 2 years to their age. If itβs after their birthday I want it to add 1 year. I just canβt get it to actually work and I wouldnβt be at all suprised if itβs all down to my nesting, which Iβm horribly at.
I would be endlessly gratful for any and all help with this. It would save me a huge head ache. Literally.
Solved! Go to Solution.
βApr 09, 2020 10:40 AM
This is an interesting case where there can be multiple approaches.
I looked up calculating Korean age and discovered that a baby is considered 1 year old at birth and gains one year every January 1. I found this method of calculating Korean age is easier than making calculations based on the current date.
Here is my formula. It calculates the age in months from Jan 1 of the current year, divides that by 12 to convert to years, then finds the next largest integer.
IF({Date},
CEILING(
DATETIME_DIFF(
TODAY(),
DATETIME_PARSE("1/1/" & YEAR({Date}), "D/M/YYYY"),
'months'
)
/ 12
)
)
This formula does not take into account the age of a person who has died, which your original formula does. However, it looks like you understand formulas well enough to implement that part yourself. (One option would be to calculate the ages of deceases people and of live people in different fields.)
βApr 09, 2020 10:40 AM
This is an interesting case where there can be multiple approaches.
I looked up calculating Korean age and discovered that a baby is considered 1 year old at birth and gains one year every January 1. I found this method of calculating Korean age is easier than making calculations based on the current date.
Here is my formula. It calculates the age in months from Jan 1 of the current year, divides that by 12 to convert to years, then finds the next largest integer.
IF({Date},
CEILING(
DATETIME_DIFF(
TODAY(),
DATETIME_PARSE("1/1/" & YEAR({Date}), "D/M/YYYY"),
'months'
)
/ 12
)
)
This formula does not take into account the age of a person who has died, which your original formula does. However, it looks like you understand formulas well enough to implement that part yourself. (One option would be to calculate the ages of deceases people and of live people in different fields.)
βApr 09, 2020 11:52 AM
Oh, CEILING(). Have never used that one before and though Iβm sure Iβve seen it on noumerous occations while browsing the Formula field reference page it hadnβt stuck in memory. Now Iβm curious to play around with it to first fully understand it and then find multiple uses for it.
Yes, Korean age is a bit funny as itβs uniqe in itβs approach. As Korea has a highly hierarcial society figuring out someoneβs age is important though. Everyone born the same year as you are automatically the same age and a βfriendβ. Anyone older require words/speech of a different hierachy. Iβm learning, but oh how I wish it was easier. Very intresting though.
Thank you so much for your help.