#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Date Formulas

I am trying to calculate the age of a person using the current "today's" date
and their birthdate without typing today's date into a cell. I do not need
the current date in a cell, due to having it in a footer. My thinking is
that it should look something like {=year(today)-year(birthdate)} I cannot
get this to work. I have their birthdates typed into a cell, but do not have
the current date.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,688
Default Date Formulas

See this:

http://cpearson.com/excel/datedif.htm

Biff

"NCCDRLEE" wrote in message
...
I am trying to calculate the age of a person using the current "today's"
date
and their birthdate without typing today's date into a cell. I do not
need
the current date in a cell, due to having it in a footer. My thinking is
that it should look something like {=year(today)-year(birthdate)} I
cannot
get this to work. I have their birthdates typed into a cell, but do not
have
the current date.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,886
Default Date Formulas

Hi

If you only want the number of years, then you were almost there with
your formula
=YEAR(TODAY())-YEAR(A1)
where A1 is holding the birthdate.
You need to format the cell with the formula as General
FormatCellsNumberGeneral otherwise an age of say 44 would show as
13/02/1900

If you require the age split out into years, months days then follow
Biff's lead to Datedif, but do take note of some of its vagaries with
certain dates.

--
Regards

Roger Govier


"NCCDRLEE" wrote in message
...
I am trying to calculate the age of a person using the current
"today's" date
and their birthdate without typing today's date into a cell. I do not
need
the current date in a cell, due to having it in a footer. My thinking
is
that it should look something like {=year(today)-year(birthdate)} I
cannot
get this to work. I have their birthdates typed into a cell, but do
not have
the current date.



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 605
Default Date Formulas

Anyone who is interested in C. Pearson's link and wonders if it is faster to use TODAY( ) instead of NOW( ) in the age calculating formula, here is a thread for additional information.

http://groups.google.ca/group/micros...c4fb16 323022

Epinn

"Biff" wrote in message ...
See this:

http://cpearson.com/excel/datedif.htm

Biff

"NCCDRLEE" wrote in message
...
I am trying to calculate the age of a person using the current "today's"
date
and their birthdate without typing today's date into a cell. I do not
need
the current date in a cell, due to having it in a footer. My thinking is
that it should look something like {=year(today)-year(birthdate)} I
cannot
get this to work. I have their birthdates typed into a cell, but do not
have
the current date.




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 618
Default Date Formulas

"Roger Govier" wrote in message
...

"NCCDRLEE" wrote in message
...
I am trying to calculate the age of a person using the current "today's"
date
and their birthdate without typing today's date into a cell. I do not
need
the current date in a cell, due to having it in a footer. My thinking is
that it should look something like {=year(today)-year(birthdate)} I
cannot
get this to work. I have their birthdates typed into a cell, but do not
have
the current date.


If you only want the number of years, then you were almost there with your
formula
=YEAR(TODAY())-YEAR(A1)
where A1 is holding the birthdate.
You need to format the cell with the formula as General
FormatCellsNumberGeneral otherwise an age of say 44 would show as
13/02/1900


That would give the age which will be achieved by the end of this year,
rather than the more usual usage which is the number of whole years already
achieved by today's date, which you could get by
=YEAR(TODAY()-(A1))-1900
(formatted as number with no decimal places).

If you require the age split out into years, months days then follow
Biff's lead to Datedif, but do take note of some of its vagaries with
certain dates.

--
David Biddulph




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,886
Default Date Formulas

Hi David

You are absolutely correct. I had tested using my own birthday, which
has already occurred this year.
However, your formula will also give the wrong result when the month
today() is the same as the month(birthday)

=INT(YEARFRAC(birthday,today(),3)) (from the Analysis Toolpak, will
also give the wrong result because of leap years)
so maybe the best for whole year ages would be

=INT((Today()-Birthday)/365.25)

--
Regards

Roger Govier


"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...

"NCCDRLEE" wrote in message
...
I am trying to calculate the age of a person using the current
"today's" date
and their birthdate without typing today's date into a cell. I do
not need
the current date in a cell, due to having it in a footer. My
thinking is
that it should look something like {=year(today)-year(birthdate)} I
cannot
get this to work. I have their birthdates typed into a cell, but do
not have
the current date.


If you only want the number of years, then you were almost there with
your formula
=YEAR(TODAY())-YEAR(A1)
where A1 is holding the birthdate.
You need to format the cell with the formula as General
FormatCellsNumberGeneral otherwise an age of say 44 would show as
13/02/1900


That would give the age which will be achieved by the end of this
year, rather than the more usual usage which is the number of whole
years already achieved by today's date, which you could get by
=YEAR(TODAY()-(A1))-1900
(formatted as number with no decimal places).

If you require the age split out into years, months days then follow
Biff's lead to Datedif, but do take note of some of its vagaries with
certain dates.

--
David Biddulph



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 618
Default Date Formulas

"Roger Govier" wrote in message
...
"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...

....
If you only want the number of years, then you were almost there with
your formula
=YEAR(TODAY())-YEAR(A1)
where A1 is holding the birthdate.
You need to format the cell with the formula as General
FormatCellsNumberGeneral otherwise an age of say 44 would show as
13/02/1900


That would give the age which will be achieved by the end of this year,
rather than the more usual usage which is the number of whole years
already achieved by today's date, which you could get by
=YEAR(TODAY()-(A1))-1900
(formatted as number with no decimal places).


Hi David

You are absolutely correct. I had tested using my own birthday, which has
already occurred this year.
However, your formula will also give the wrong result when the month
today() is the same as the month(birthday)


You've confused me there, Roger. I can't see why that should be the case
(as the calculation of the month doesn't come into my formula), and when I
test it with birthdays in October it shows the age changing for dates on or
before 12th October, as I would expect.

The only situation where I can foresee that there might be a difficulty is
around leap years, with the question of when someone born on 29th Feb
celebrates their birthday (without resorting to the Pirates of Penzance!).
--
David Biddulph


  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,886
Default Date Formulas

Hi David

Don't know what's going on here.
When I enter 11/10/1944 in A1
=YEAR(TODAY()-(A1))-1900
returns 61
30/09/1944 returns 62
but all October dates return 61
--
Regards

Roger Govier


"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...
"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...

...
If you only want the number of years, then you were almost there
with your formula
=YEAR(TODAY())-YEAR(A1)
where A1 is holding the birthdate.
You need to format the cell with the formula as General
FormatCellsNumberGeneral otherwise an age of say 44 would show
as 13/02/1900


That would give the age which will be achieved by the end of this
year, rather than the more usual usage which is the number of whole
years already achieved by today's date, which you could get by
=YEAR(TODAY()-(A1))-1900
(formatted as number with no decimal places).


Hi David

You are absolutely correct. I had tested using my own birthday, which
has already occurred this year.
However, your formula will also give the wrong result when the month
today() is the same as the month(birthday)


You've confused me there, Roger. I can't see why that should be the
case (as the calculation of the month doesn't come into my formula),
and when I test it with birthdays in October it shows the age changing
for dates on or before 12th October, as I would expect.

The only situation where I can foresee that there might be a
difficulty is around leap years, with the question of when someone
born on 29th Feb celebrates their birthday (without resorting to the
Pirates of Penzance!).
--
David Biddulph




  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 618
Default Date Formulas

I see what you mean, but are you sure that it's all dates in October, and
not just yesterday (11th Oct)? Doesn't 9/10/44 or 10/10/44 give 62?

I get the impression that we may just be a day adrift for some years, and my
guess is that it's tied up with leap years, but you're right that my simple
formula isn't 100% reliable. Thanks for pointing it out.
--
David Biddulph

"Roger Govier" wrote in message
...
Hi David

Don't know what's going on here.
When I enter 11/10/1944 in A1
=YEAR(TODAY()-(A1))-1900
returns 61
30/09/1944 returns 62
but all October dates return 61
--
Regards

Roger Govier


"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...
"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...

...
If you only want the number of years, then you were almost there with
your formula
=YEAR(TODAY())-YEAR(A1)
where A1 is holding the birthdate.
You need to format the cell with the formula as General
FormatCellsNumberGeneral otherwise an age of say 44 would show as
13/02/1900


That would give the age which will be achieved by the end of this year,
rather than the more usual usage which is the number of whole years
already achieved by today's date, which you could get by
=YEAR(TODAY()-(A1))-1900
(formatted as number with no decimal places).


Hi David

You are absolutely correct. I had tested using my own birthday, which
has already occurred this year.
However, your formula will also give the wrong result when the month
today() is the same as the month(birthday)


You've confused me there, Roger. I can't see why that should be the case
(as the calculation of the month doesn't come into my formula), and when
I test it with birthdays in October it shows the age changing for dates
on or before 12th October, as I would expect.

The only situation where I can foresee that there might be a difficulty
is around leap years, with the question of when someone born on 29th Feb
celebrates their birthday (without resorting to the Pirates of
Penzance!).
--
David Biddulph






  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,886
Default Date Formulas

Hi David

Just tried it again and it returns 62 up to 10 Oct 1944 and 61
thereafter.
Not consistent with what I was seeing before.

I set up a table of dates from 30/09/44 through 11/11/44 down column A,
then filled through for 12 columns so I have from 30/09/44 to 11/11/56.
Copied the formula across as appropriate and then switch from 1 year to
one lower year seems to occur after 11/10 for years 44 and 45, 12/10 for
year 46 and 47, back to 11/10 years 48 and 49 and continues this pattern
of switching after every pair of years

It must be something to do with leap year and Rounding in Excel's
calculation.

I'm not going to give it any more thought!!!!

I have long since discovered that there is no foolproof method of
consistent calculation of date intervals other than the straight
subtraction of one date from another and returning the number of days.

"Sod" was obviously alive and well when our planetary system was formed
giving rise to a cycle around the Sun that is not an exact number of
days, let alone weeks and with a calendar devised which incorporates
such a disparate set of day ranges, how on earth can anyone expect to
get it right<vbg

--
Regards

Roger Govier


"David Biddulph" wrote in message
...
I see what you mean, but are you sure that it's all dates in October,
and not just yesterday (11th Oct)? Doesn't 9/10/44 or 10/10/44 give
62?

I get the impression that we may just be a day adrift for some years,
and my guess is that it's tied up with leap years, but you're right
that my simple formula isn't 100% reliable. Thanks for pointing it
out.
--
David Biddulph

"Roger Govier" wrote in message
...
Hi David

Don't know what's going on here.
When I enter 11/10/1944 in A1
=YEAR(TODAY()-(A1))-1900
returns 61
30/09/1944 returns 62
but all October dates return 61
--
Regards

Roger Govier


"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...
"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...
...
If you only want the number of years, then you were almost there
with your formula
=YEAR(TODAY())-YEAR(A1)
where A1 is holding the birthdate.
You need to format the cell with the formula as General
FormatCellsNumberGeneral otherwise an age of say 44 would show
as 13/02/1900

That would give the age which will be achieved by the end of this
year, rather than the more usual usage which is the number of
whole years already achieved by today's date, which you could get
by
=YEAR(TODAY()-(A1))-1900
(formatted as number with no decimal places).

Hi David

You are absolutely correct. I had tested using my own birthday,
which has already occurred this year.
However, your formula will also give the wrong result when the
month today() is the same as the month(birthday)

You've confused me there, Roger. I can't see why that should be the
case (as the calculation of the month doesn't come into my formula),
and when I test it with birthdays in October it shows the age
changing for dates on or before 12th October, as I would expect.

The only situation where I can foresee that there might be a
difficulty is around leap years, with the question of when someone
born on 29th Feb celebrates their birthday (without resorting to the
Pirates of Penzance!).
--
David Biddulph










  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 605
Default Date Formulas

Do you want to know what function I prefer?

I still like DATEDIF even though I don't need the number of months and the number of days.

=DATEDIF(A1,TODAY(),"y")

I tested this formula on July which has passed, on December which is to happen and even on 10/12/2005. The formula passed all three tests and I got one year for October 12, 2005 (birthdate).

I hope MS won't take DATEDIF away in the future. Last night, I was wondering whether it is faster to use DATEDIF or to just do date2 - date1. I think I should give my brain a rest.

Epinn

"Roger Govier" wrote in message ...
Hi David

Just tried it again and it returns 62 up to 10 Oct 1944 and 61
thereafter.
Not consistent with what I was seeing before.

I set up a table of dates from 30/09/44 through 11/11/44 down column A,
then filled through for 12 columns so I have from 30/09/44 to 11/11/56.
Copied the formula across as appropriate and then switch from 1 year to
one lower year seems to occur after 11/10 for years 44 and 45, 12/10 for
year 46 and 47, back to 11/10 years 48 and 49 and continues this pattern
of switching after every pair of years

It must be something to do with leap year and Rounding in Excel's
calculation.

I'm not going to give it any more thought!!!!

I have long since discovered that there is no foolproof method of
consistent calculation of date intervals other than the straight
subtraction of one date from another and returning the number of days.

"Sod" was obviously alive and well when our planetary system was formed
giving rise to a cycle around the Sun that is not an exact number of
days, let alone weeks and with a calendar devised which incorporates
such a disparate set of day ranges, how on earth can anyone expect to
get it right<vbg

--
Regards

Roger Govier


"David Biddulph" wrote in message
...
I see what you mean, but are you sure that it's all dates in October,
and not just yesterday (11th Oct)? Doesn't 9/10/44 or 10/10/44 give
62?

I get the impression that we may just be a day adrift for some years,
and my guess is that it's tied up with leap years, but you're right
that my simple formula isn't 100% reliable. Thanks for pointing it
out.
--
David Biddulph

"Roger Govier" wrote in message
...
Hi David

Don't know what's going on here.
When I enter 11/10/1944 in A1
=YEAR(TODAY()-(A1))-1900
returns 61
30/09/1944 returns 62
but all October dates return 61
--
Regards

Roger Govier


"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...
"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...
...
If you only want the number of years, then you were almost there
with your formula
=YEAR(TODAY())-YEAR(A1)
where A1 is holding the birthdate.
You need to format the cell with the formula as General
FormatCellsNumberGeneral otherwise an age of say 44 would show
as 13/02/1900

That would give the age which will be achieved by the end of this
year, rather than the more usual usage which is the number of
whole years already achieved by today's date, which you could get
by
=YEAR(TODAY()-(A1))-1900
(formatted as number with no decimal places).

Hi David

You are absolutely correct. I had tested using my own birthday,
which has already occurred this year.
However, your formula will also give the wrong result when the
month today() is the same as the month(birthday)

You've confused me there, Roger. I can't see why that should be the
case (as the calculation of the month doesn't come into my formula),
and when I test it with birthdays in October it shows the age
changing for dates on or before 12th October, as I would expect.

The only situation where I can foresee that there might be a
difficulty is around leap years, with the question of when someone
born on 29th Feb celebrates their birthday (without resorting to the
Pirates of Penzance!).
--
David Biddulph









  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 605
Default Date Formulas

Further test with my formula ......

10/15/2005 yields 0 whereas 10/15/2004 yields 1. I think this is acceptable.

I won't go into leap year here as I started a thread on DATEDIF and leap year yesterday.

Thank you for reading.

Epinn

"Epinn" wrote in message ...
Do you want to know what function I prefer?

I still like DATEDIF even though I don't need the number of months and the number of days.

=DATEDIF(A1,TODAY(),"y")

I tested this formula on July which has passed, on December which is to happen and even on 10/12/2005. The formula passed all three tests and I got one year for October 12, 2005 (birthdate).

I hope MS won't take DATEDIF away in the future. Last night, I was wondering whether it is faster to use DATEDIF or to just do date2 - date1. I think I should give my brain a rest.

Epinn

"Roger Govier" wrote in message ...
Hi David

Just tried it again and it returns 62 up to 10 Oct 1944 and 61
thereafter.
Not consistent with what I was seeing before.

I set up a table of dates from 30/09/44 through 11/11/44 down column A,
then filled through for 12 columns so I have from 30/09/44 to 11/11/56.
Copied the formula across as appropriate and then switch from 1 year to
one lower year seems to occur after 11/10 for years 44 and 45, 12/10 for
year 46 and 47, back to 11/10 years 48 and 49 and continues this pattern
of switching after every pair of years

It must be something to do with leap year and Rounding in Excel's
calculation.

I'm not going to give it any more thought!!!!

I have long since discovered that there is no foolproof method of
consistent calculation of date intervals other than the straight
subtraction of one date from another and returning the number of days.

"Sod" was obviously alive and well when our planetary system was formed
giving rise to a cycle around the Sun that is not an exact number of
days, let alone weeks and with a calendar devised which incorporates
such a disparate set of day ranges, how on earth can anyone expect to
get it right<vbg

--
Regards

Roger Govier


"David Biddulph" wrote in message
...
I see what you mean, but are you sure that it's all dates in October,
and not just yesterday (11th Oct)? Doesn't 9/10/44 or 10/10/44 give
62?

I get the impression that we may just be a day adrift for some years,
and my guess is that it's tied up with leap years, but you're right
that my simple formula isn't 100% reliable. Thanks for pointing it
out.
--
David Biddulph

"Roger Govier" wrote in message
...
Hi David

Don't know what's going on here.
When I enter 11/10/1944 in A1
=YEAR(TODAY()-(A1))-1900
returns 61
30/09/1944 returns 62
but all October dates return 61
--
Regards

Roger Govier


"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...
"David Biddulph" wrote in message
...
"Roger Govier" wrote in message
...
...
If you only want the number of years, then you were almost there
with your formula
=YEAR(TODAY())-YEAR(A1)
where A1 is holding the birthdate.
You need to format the cell with the formula as General
FormatCellsNumberGeneral otherwise an age of say 44 would show
as 13/02/1900

That would give the age which will be achieved by the end of this
year, rather than the more usual usage which is the number of
whole years already achieved by today's date, which you could get
by
=YEAR(TODAY()-(A1))-1900
(formatted as number with no decimal places).

Hi David

You are absolutely correct. I had tested using my own birthday,
which has already occurred this year.
However, your formula will also give the wrong result when the
month today() is the same as the month(birthday)

You've confused me there, Roger. I can't see why that should be the
case (as the calculation of the month doesn't come into my formula),
and when I test it with birthdays in October it shows the age
changing for dates on or before 12th October, as I would expect.

The only situation where I can foresee that there might be a
difficulty is around leap years, with the question of when someone
born on 29th Feb celebrates their birthday (without resorting to the
Pirates of Penzance!).
--
David Biddulph










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mileage Claim Formula johndavies New Users to Excel 4 August 14th 06 09:24 AM
Need to Improve Code Copying/Pasting Between Workbooks David Excel Discussion (Misc queries) 1 January 6th 06 03:56 AM
Date formulas needed David Excel Discussion (Misc queries) 9 July 24th 05 02:01 AM
Min/Max formulas using cells with date format WDS2000 Excel Worksheet Functions 1 February 7th 05 06:03 PM
Using formulas to determine date in one cell based on date in anot Gary Excel Worksheet Functions 2 November 22nd 04 08:11 AM


All times are GMT +1. The time now is 02:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"