# Tech Off Post

View Thread: calculating age - getting more details
• evildictaitor said:
It looks like you're trying to get the lexical difference between two dates (the lexical distance between 1 Jan and 1 Feb is the same as the distance between 1 Feb and 1 Mar - 1 month, even though it's a different number of days)

You've actually made a mistake though - it's 3 months only after we get to April 17:  (Jan17 --> Feb17 = 1 month, Feb17 --> Mar17 = 2month, Mar17 --> Apr17 = 3month)

To do it, you just do what you do for (long) subtraction  (writing the date in yyyy/mm/dd format is best)

2009 / 04 / 06
- 1982 / 01 / 17
------------------
Y     / M   / D

D = 06 - 17, but that's negative, so we need to 'borrow' one from the month category. The number of days 'borrowed' is the number of days in the previous month:

2009 / 03 / 37
- 1982 / 01 / 17
---------------
Y    / M / 20

For M, we don't need to 'borrow' months from the previous column, since 3 > 1, but if we did, we would borrow the number of months in the previous year, which is always going to be 12.

The result is then

2009 / 03 / 37
- 1982 / 01 / 17
-----------------
27  / 02 / 20

So you are 27 years, 2 months and 20 days old
Thanks!