A
A
Alina Shah2020-04-27 16:12:44
Google Sheets
Alina Shah, 2020-04-27 16:12:44

How to make a universal age calculation formula?

=YEAR(TODAY())-YEAR(A7)
For some reason it does not work when the age is large
and almost the same situation, with a different formula - it does not work if the year is less than 1900 and even in some cases from 1900-1999:
=C7-LEFT( DAY(DATEVALUE(A7));1)*2
https://docs.google.com/spreadsheets/d/1vqKnsN_8qQ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2020-04-27
@Shah_Alina

Kind of a bunch of questions. Perhaps it is worth paying attention to some specific problem.
5ea6dd9fa3c2a573383387.png
It's not "buggy". This is a property of computing systems. You can take it into service: every day in Google Sheets is an integer from the date "12/31/1899". A negative number is years in the past.
Unfortunately, date formulas don't work with negative numbers. But on the other hand, type casting does not negate the fact that any digits by default will be represented as numbers, and not as strings.
For example,
=TEXT(TODAY();"YYYY")-TEXT(A7;"YYYY")
For days and months, with this approach, leading zeros may appear. "cutting" them is best through VALUE
=VALUE(TEXT(TODAY();"YYYY"))-VALUE(TEXT(A7;"DD"))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question