Aug 26, 2023 03:10 AM
I am struggling to get a Formula that would return my age, where the number after the decimal point indicates the number of months in duodecimal format. For example, my current age is 34 years and 3 months, therefore I want to see 34.03 as the return.
So far I've managed to only get this:
the formula I am using is:
Solved! Go to Solution.
Aug 26, 2023 07:02 AM
It is more difficult than I thought!
How about this
String Ver.
DATETIME_DIFF(TODAY(),DoB,"Year")&
"."&
SWITCH(DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12,
11, "",
10, "",
"0"
)&
IF(DATETIME_DIFF(TODAY(),DoB,"Month")>=0,
DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12,
DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12+12
)
Numeric Ver.
DATETIME_DIFF(TODAY(),DoB,"Year")
+
IF(DATETIME_DIFF(TODAY(),DoB,"Month")>=0,
(DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12)/10,
(DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12+12)/10
)
/
SWITCH((DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year"))*12,
11, 1,
10, 1,
10
)
Aug 26, 2023 07:02 AM
It is more difficult than I thought!
How about this
String Ver.
DATETIME_DIFF(TODAY(),DoB,"Year")&
"."&
SWITCH(DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12,
11, "",
10, "",
"0"
)&
IF(DATETIME_DIFF(TODAY(),DoB,"Month")>=0,
DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12,
DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12+12
)
Numeric Ver.
DATETIME_DIFF(TODAY(),DoB,"Year")
+
IF(DATETIME_DIFF(TODAY(),DoB,"Month")>=0,
(DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12)/10,
(DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12+12)/10
)
/
SWITCH((DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year"))*12,
11, 1,
10, 1,
10
)
Aug 27, 2023 07:31 PM
It worked for me like a charm! Thank you very much 🙌
Aug 27, 2023 09:25 PM
I recall the existence of the MOD function.
It is simpler.
String ver.
DATETIME_DIFF(TODAY(),DoB,"Year")&
"."&
SWITCH(DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12,
11, "",
10, "",
"0"
)&
MOD((DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12),12)
Numeric Ver.
DATETIME_DIFF(TODAY(),DoB,"Year")
+
MOD((DATETIME_DIFF(TODAY(),DoB,"Month")-DATETIME_DIFF(TODAY(),DoB,"Year")*12),12)/100
Aug 28, 2023 10:02 PM
There's a terrible, brute-force way of doing the padded decimal portion:
RIGHT("0" & {Month Difference}, 2)