|
-
Feb 15th, 2009, 09:13 AM
#1
[RESOLVED] Age Calculation
Lets say you are born on 1/1/2000 @ 12:00:01 AM. You are one day old correct?
On 1/2/2000 you are 2 days old.
On 1/8/2000 you are 1 week old.
On 1/15/2000 you are 2 weeks old.
On 12/31/2000 you are 366 days old. (leap year)
Therefore, on 1/1/2001 aren't you 1 year and 1 day old?
I ask because I have an issue with an age calculator that I wrote.
Last edited by dbasnett; Feb 15th, 2009 at 10:06 AM.
-
Feb 15th, 2009, 09:42 AM
#2
Hyperactive Member
Re: Age Calculation
Hi DBasnett,
I think you meant 1/1/2001 on the last line of your post. I think you're right. At least as far as we casually consider our ages. I suppose you could calculate the number of days that have elapsed from birth to current and then divide by 365.24 (and how many other decimal places that I don't know) to figure out a more precise age. I guess it depends on how you want to look at what a year is.
-
Feb 15th, 2009, 10:14 AM
#3
Re: Age Calculation
thanks for the catch, i fixed it in the original. i am still working on it, trying to have it both ways without creating a huge kludge. it works great, including leap years, for everything but the anniversary date (birth date).
-
Feb 15th, 2009, 10:20 AM
#4
Hyperactive Member
Re: Age Calculation
what's the problem with the anniversary date?
-
Feb 15th, 2009, 10:30 AM
#5
Re: Age Calculation
anniversary is a date in the past, like birthday. here are my results:
birthday = 1/1/2000 - 2000 is leap year
On 1/1/2000 - 0 days old
On 1/2/2000 - 2 days old
On 1/8/2000 - 8 days old
On 12/31/2000 - 366 days old
On 1/1/2001 - 1 year 0 days old
On 1/2/2001 - 1 year 2 days old
On 12/31/2001 - 1 year 365 days old
-
Feb 15th, 2009, 10:44 AM
#6
Hyperactive Member
Re: Age Calculation
hmm... I just thought of something. I think it would make sense to define a year with a fractional number of days (365.24...) and just divide the number of days by that number to get their age.
The reason I think you should go that way is, what happens if say someone is born March 1 in a leap year. After how many days would they be considered 1 year old according to the calculator?
Edit: Shouldn't a year be the same number of days even if it is a leap year? a leap year just adds an extra day before we can change the calendar year, it doesn't add another day to an actual year.
Last edited by wy125; Feb 15th, 2009 at 10:49 AM.
-
Feb 15th, 2009, 10:55 AM
#7
Re: Age Calculation
 Originally Posted by dbasnett
Lets say you are born on 1/1/2000 @ 12:00:01 AM. You are one day old correct?
I kind of take issue with this statement.
Are you saying that at one second into your life you are one day old?
-
Feb 15th, 2009, 11:00 AM
#8
Re: Age Calculation
format of output
birthday asOfDate age
method1
1/1/2000 1/1/2000 yrs = 0 days = 1
1/1/2000 1/2/2000 yrs = 0 days = 2
1/1/2000 12/31/2000 yrs = 0 days = 366
1/1/2000 1/1/2001 yrs = 1 days = 1
1/1/2000 1/2/2001 yrs = 1 days = 2
1/1/2000 12/31/2001 yrs = 1 days = 365
1/1/2000 1/1/2002 yrs = 2 days = 1
1/1/2000 12/31/2004 yrs = 4 days = 366
2/29/2000 3/1/2001 yrs = 1 days = 1
2/29/2000 2/28/2003 yrs = 2 days = 365
2/29/2000 3/1/2003 yrs = 3 days = 1
2/29/2000 3/1/2004 yrs = 4 days = 2
method 2
1/1/2000 1/1/2000 yrs = 0 days = 0
1/1/2000 1/2/2000 yrs = 0 days = 2
1/1/2000 12/31/2000 yrs = 0 days = 366
1/1/2000 1/1/2001 yrs = 1 days = 0
1/1/2000 1/2/2001 yrs = 1 days = 2
1/1/2000 12/31/2001 yrs = 1 days = 365
1/1/2000 1/1/2002 yrs = 2 days = 0
1/1/2000 12/31/2004 yrs = 4 days = 366
2/29/2000 3/1/2001 yrs = 1 days = 0
2/29/2000 2/28/2003 yrs = 2 days = 365
2/29/2000 3/1/2003 yrs = 3 days = 0
2/29/2000 3/1/2004 yrs = 4 days = 2
Last edited by dbasnett; Feb 15th, 2009 at 11:05 AM.
-
Feb 15th, 2009, 11:15 AM
#9
Re: Age Calculation
i think this is the correct answer
2000 and 2004 are leap years
1/1/2000 1/1/2000 yrs = 0 days = 0
1/1/2000 1/2/2000 yrs = 0 days = 1
1/1/2000 12/31/2000 yrs = 0 days = 365
1/1/2000 1/1/2001 yrs = 1 days = 0
1/1/2000 1/2/2001 yrs = 1 days = 1
1/1/2000 12/31/2001 yrs = 1 days = 364
1/1/2000 1/1/2002 yrs = 2 days = 0
1/1/2000 12/31/2004 yrs = 4 days = 365
2/29/2000 3/1/2001 yrs = 1 days = 0
2/29/2000 2/28/2003 yrs = 2 days = 364
2/29/2000 3/1/2003 yrs = 3 days = 0
2/29/2000 2/29/2004 yrs = 4 days = 0
2/29/2000 3/1/2004 yrs = 4 days = 1
-
Feb 15th, 2009, 11:24 AM
#10
Re: Age Calculation
final test
Code:
2/29/1008 3/1/2009 yrs = 1001 days = 0
-
Feb 15th, 2009, 11:38 AM
#11
Re: Age Calculation
thanks for helping everyone. i had been thinking about this since early yesterday afternoon. it is funny how something so simple can get hard if you think about it too much.
Code:
2/29/1008 2/28/2009 yrs = 1000 days = 365
-
Feb 15th, 2009, 12:45 PM
#12
Re: [RESOLVED] Age Calculation
You are one day old on the second day, because the first day has completed. It's similar to you being one year old after the completion of a year.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|