A person’s age indicates the number of full years that the person has been alive. The formula in
the previous section (for calculating the number of years between two dates) won’t calculate this
value correctly. You can use two other formulas, however, to calculate a person’s age.
The following formula returns the age of the person whose date of birth you enter into cell A1.
This formula uses the YEARFRAC function:
=INT(YEARFRAC(TODAY(),A1,1))
The following formula uses the DATEDIF function to calculate an age. (See the sidebar, “Where’s
the DATEDIF function?”)
=DATEDIF(A1,TODAY(),”y”)
Determining the day of the year
January 1 is the first day of the year, and December 31 is the last day. But what about all of those
days in between? The following formula returns the day of the year for a date stored in cell A1:
=A1-DATE(YEAR(A1),1,0)
The day argument supplied is zero, calling for the “0th” day of the first month. The DATE func-
tion interprets this as the day before the first day, or December 31 of the previous year in this
example. Similarly, negative numbers can be supplied for the day argument.
the previous section (for calculating the number of years between two dates) won’t calculate this
value correctly. You can use two other formulas, however, to calculate a person’s age.
The following formula returns the age of the person whose date of birth you enter into cell A1.
This formula uses the YEARFRAC function:
=INT(YEARFRAC(TODAY(),A1,1))
The following formula uses the DATEDIF function to calculate an age. (See the sidebar, “Where’s
the DATEDIF function?”)
=DATEDIF(A1,TODAY(),”y”)
Determining the day of the year
January 1 is the first day of the year, and December 31 is the last day. But what about all of those
days in between? The following formula returns the day of the year for a date stored in cell A1:
=A1-DATE(YEAR(A1),1,0)
The day argument supplied is zero, calling for the “0th” day of the first month. The DATE func-
tion interprets this as the day before the first day, or December 31 of the previous year in this
example. Similarly, negative numbers can be supplied for the day argument.
No comments:
Post a Comment