Hello everyone, Please I would like a APP Formula to calculate age in Years, months and days
I used this formula but the result is wrong.
IF(
TODAY() >= [Birthday],
(
IFS(
YEAR(TODAY()) - YEAR([Birthday]) = 0, "",
YEAR(TODAY()) - YEAR([Birthday]) = 1, "1 An ",
TRUE, (YEAR(TODAY()) - YEAR([Birthday])) & " Ans "
)
&
IFS(
OR(
MONTH(TODAY()) < MONTH([Birthday]),
AND(
MONTH(TODAY()) = MONTH([Birthday]),
DAY(TODAY()) < DAY([Birthday])
)
),
(12 + MONTH(TODAY()) - MONTH([Birthday])) & " M ",
MONTH(TODAY()) = MONTH([Birthday]),
"",
TRUE, (MONTH(TODAY()) - MONTH([Birthday])) & " M "
)
&
IFS(
DAY(TODAY()) < DAY([Birthday]),
(DAY(EOMONTH(TODAY(), -1)) + DAY(TODAY()) - DAY([Birthday])) & " J",
DAY(TODAY()) = DAY([Birthday]),
"",
TRUE, (DAY(TODAY()) - DAY([Birthday])) & " J"
)
),
""
)
I got this result
36 Ans 11 M 23 J
for this date of birth
June 6, 1988
while the result should be
35 Years 11 M 23 D
Thank you so much
From this thread, it looks like the following might work:
FLOOR(HOUR(TODAY()-[Birthday])/365/24)&" Years "&
FLOOR(MOD((HOUR(TODAY()-[Birthday])/24),365)*12/365) & " M"
&CONCATENATE(
IF(
(
(
HOUR(
TODAY()
- (
EOMONTH(TODAY(), -2)
+ DAY([Birthday])
)
)
/ 24
)
< (
HOUR(
TODAY()
- (
EOMONTH(TODAY(), -2)
+ DAY(TODAY())
)
)
/ 24
)
),
(
HOUR(
TODAY()
- (
EOMONTH(TODAY(), -2)
+ DAY([Birthday])
)
)
/ 24
),
(
HOUR(
TODAY()
- (
EOMONTH(TODAY(), -1)
+ DAY([Birthday])
)
)
/ 24
)
),
" D"
)
Hello lynchk21,
I would like to thank you warmly for your help and for offering me a solution for my formula. Although the initial formula didn't work as expected and there was always an extra year, your suggestion really helped me understand the problem better.
I also wanted to let you know that I finally found a solution that works perfectly, and I would be happy to share it if it can be helpful in the future.
Once again, thank you for your time and generosity.
Best regards,
""CONCATENATE( YEAR(TODAY()) - YEAR([Birthday]) - IF(MONTH(TODAY()) < MONTH([Birthday]) OR (MONTH(TODAY()) = MONTH([Birthday]) AND DAY(TODAY()) < DAY([Birthday])), 1, 0), " Ans ", IF(MONTH(TODAY()) >= MONTH([Birthday]), MONTH(TODAY()) - MONTH([Birthday]), 12 + MONTH(TODAY()) - MONTH([Birthday])), " M ", IF(DAY(TODAY()) >= DAY([Birthday]), DAY(TODAY()) - DAY([Birthday]), DAY(EOMONTH(TODAY(),-1)) + DAY(TODAY()) - DAY([Birthday])), " J" ) ""
Nice! Thanks for sharing!
User | Count |
---|---|
15 | |
10 | |
6 | |
5 | |
5 |