You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Calculate duration with a decimal

So this is my 2nd post, since I can't even find the 1st.... so sorry in advance.


I'm trying to calculate how old I am in years, with a single decimal point. I have a field with my birthdate, and one field with today's date, and subtracting one from the other gives me the result in weeks... which I divid by 52 to give me years. The problem is I'd like the result to have a single decimal but don't see how to make that happen.... Any ideas?

iMac 27" 5K, macOS 10.14

Posted on Jan 28, 2020 3:16 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 28, 2020 3:59 PM

HI Jeffrey,


I'd use DATEDIF to calculate the number of Days between your birthdate and TODAY. Dividing the number of days by 365.25 will give you a more precise result than counting weeks and dividing by 25.


Here are the results, at 17 day intervals, for the age in years of a person born January 1, 2000.



Formula in C2: DATEDIF(A2,B2,"D")


Formula in D2: C2÷365.25


For the example, both are filled down to the last row in the column.


For your finished version, using only cells A2, B2 and C2, use these :


A2: enter your birthdate


B2: enter as a formula: TODAY()


C2: DATEDIF(A2,B2,"D")/365.25


Set the Data Format for C2 as shown above for column D of the example, but set the Decimals stepper to 1.


Regards,

Barry

5 replies
Question marked as Top-ranking reply

Jan 28, 2020 3:59 PM in response to Jeffrey Lee

HI Jeffrey,


I'd use DATEDIF to calculate the number of Days between your birthdate and TODAY. Dividing the number of days by 365.25 will give you a more precise result than counting weeks and dividing by 25.


Here are the results, at 17 day intervals, for the age in years of a person born January 1, 2000.



Formula in C2: DATEDIF(A2,B2,"D")


Formula in D2: C2÷365.25


For the example, both are filled down to the last row in the column.


For your finished version, using only cells A2, B2 and C2, use these :


A2: enter your birthdate


B2: enter as a formula: TODAY()


C2: DATEDIF(A2,B2,"D")/365.25


Set the Data Format for C2 as shown above for column D of the example, but set the Decimals stepper to 1.


Regards,

Barry

Jan 28, 2020 3:34 PM in response to Jeffrey Lee

Ok so

FINALLY found the info I needed


Field 1 Birthdate

Field 2 Todays Date (=Today)

Field 3 Difference =DUR2WEEKS(G42−F42) (where G42 is my birthday, and G43 is Today

Filed 4 Years calculation. =H42÷52. (where H42 is the data in Field #3 above.


This give me my age with a single decimal point, which is exactly what I was trying to do!


I just don't use these advanced(advanced for me) formulas as much, so this is the edge I'm always falling off of

Jan 28, 2020 4:31 PM in response to Jeffrey Lee

HI again,


Regarding automatic updating—TODAY (and other functions) won't do that without being nudged.

If you close the document each day, then open it the next, the action of opening the document will trigger the recalculation.


Annother was is to make the DATADIF formula dependent on the setting of a checkbox cell. You could tell TODAY to calculate when the checkbox is 'true' (checked) or tell it to calculate when the checkbox is 'false' (unchecked). Either of thise would require two clicks to trigger the recalculation.


To reduce that to a single click, set up your formula to calculate on both conditions, effectively triggering the recalculation whenever the cell's setting is changed.


Checkbox in D2, formula in C2.


C2: IF(D2,DATEDIF(A2,B2,"D")/365.25,DATEDIF(A2,B2,"D")/365.25)


Regards,

Barry

Calculate duration with a decimal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.