Formula FLOOR(HOUR(TODAY()-[DOB])/365/24)&" yr "& FLOOR(MOD((HOUR(TODAY()-[DOB])/24),365)*12/365) & " mo"
Line 1 HOUR(TODAY()-[DOB]) returns the number of Hours in the duration /365/24 converts hours to years, and FLOOR gives the number of full years, dropping the decimal.
Line 2 (HOUR(TODAY()-[DOB])/24) returns the number of days in the duration MOD((...),365) finds the remainder in days, after removing the full-years FLOOR(MOD(...)*12/365) converts those remaining days to months, dropping the decimal.
This could also be used to show other durations, such as a count down to a future date.
FLOOR(HOUR(TODAY()-[DOB])/365/24)&" yr "&
FLOOR(MOD((HOUR(TODAY()-[DOB])/24),365)*12/365) & " mo " &
IF(
DAY(TODAY())>=DAY([DOB]),
DAY(TODAY())-DAY([DOB]),
DAY(TODAY())+FLOOR(HOUR(EOMONTH([DOB],0)-[DOB])/24)
) & " days"
I tried the MOD() method, but the numbers always seemed off because of months having different number of days. So I went with the DAY() -number of TODAY() compared to the DAY([DOB]).
I haven’t fully tested it yet. You might see something like X yrs X mo 32 days or -1 days, depending on how the dates line up.
Lol yes, I am not neat with my formulas and usually just keep throwing stuff in there til they work. Thanks for cleaning that up!
I also came up with the formula below that ensures that the month number is dependent on the anniversary day of the month. The one above would occasionally calculate the wrong month as you approached the anniversary day.
I have a column with Date (DD/MM/YYYY) datatype in which I want to select the only MM/YYYY and the date should be fixed like the 1st date of every month.
So is this possible in the AppSheet?
for example for today on 19th oct 21 and due date 20 jan 22 it is calculating 3 month 11 days instead of 3 months 1 day, I think i made some error in last step can anybody figure it out and help ! thanks in advance.