Accurate Age Calculation

Oh and I think that 0.0 is 31/12/1899
It is actually Midnight on the 30/12/1899.
31/12/1899 Midnight is 1.

This has something to do with the Year of 1900 which was thought to be a Leap Year, which it isn't. You would need to Google to find a full explanation.
 
Rain.

>>What is wrong with the following?<<
Code:
MsgBox Format(Now() - [DOB], "yyyy")    [color=green]' < 2012 (Years)[/color]
should have been:-
MsgBox Format(Now() - [DOB], "yyyy")    [color=green]' < 2012 (Year)[/color]
That is why I dislike comments in code. :D

Chris.
 
Many Thanks to you all for your input :eek:
I had assumed that the expression that I had entered would give me an Age in YY/MM/DD, the fact that it was only giving me YY, I assumed was down to my lack of correct formatting - I now presume that this is not the case ?
When I said that I wanted an accrurate age, what I should have said is that I would like an age as accurate as a normally adjusted human being would accept, YY/MM/DD would be fine, bearing in mind that I am only starting from a DOB. So could we simply work on the assumption that the DOB is GMT, and it really doesn't matter whether the person is descended from convicted horse thieves (of any age-(the horses that is)) in the antipodies or indeed eskimos, mounted or otherwise.
As long as I can determine whether someone is under 25 years (UK Imperial) old on the 31st. Dec. (Gregorian) of each year, regardless of whether it is a leap year, or indeed the earth's orbit has adjusted slightly relative to the atomic clock; and also highlight several other notable birthdays, as well as years of membership, that will be fine.
I now need to go and do some work, so my apologies, but I will have to leave going through these various suggestions until the weekend. In the meantime I'm going to check my horses teeth to see whether he was born next year, and perhaps spend tomorrow having my own teeth drilled.
I was going to post another thread on a separate issue, but my therapist has advised against it, and said I should sit quietly in a darkened room until the impulse goes away.
Regards
 
Negger

I can't wait till ChrisO reads this reply.

The next thing he will want to know is how old is a snake that is lying half each side on the GMT.

In my signature there is a link to my Sky Drive. It has a Sample Database for anyone to download.

I think it is correct. Only tested by me in A 2003. Should run in any version. It also calculates negative Age or if you prefer an event that will happen some time in the future.

It gives Whole Years in one Box and Years Months Days in the other. Takes into account leap years etc.

The calculation using (DOB - NOW) will not work. AFAIK.

Please let me know if you can fault anything at all. PM If you have to, please.

You should be able to work out what goes where based upon the sample.
 
Last edited:
DateDiff("yyyy", DOB, Date)

Chris.
 
ChrisO

Itis late. Have a coffee and go to bed. Count horses if you can't sleep.
 
@Rain

And what if the snake spans across the Date Line?
 
That would surely depend upon whether it was facing West or East ? And of course a horse could be straddling it either N/S or E/W, so presumably it's head could be a day younger than it's tail, even though the head was born first, even if it isn't born till next year ?
When I get to 10 posts I'll be able to look at your links, Many Thanks; and there I was thinking that this was a basic simple problem to overcome.
We've just enjoyed the Queen's official birthday and the Trooping of the Colours; when do you get to enjoy that, Yesterday or tomorrow ?
 
Having answered my question you now have 10 Posts.

Links should now work for you.
 
Hi RainLover,
Many Thanks for Demo, that's just what I'm looking for. I've now got a field up and running by copying what you've done.:D
I presume the Module is what's doing the business ?
& I presume the Table & Query are unecessary in my case (I don't want to store this Age date)
There are a few other things I want to play around with now, but I'll put up a separate post for that if I get stuck.
Once again many thanks, I'd never have got ther without you!
 
Greetings:

I have seen so much misinformation on the internet about age calculations.

Let's start with the leap year issue.

Microsoft date/time fields know precisely when leap years occur in the Gregorian calendar we use. If you try to enter Feb 29 in any year except a valid leap year, you will get an error message. So calculating the correct age from DOB has nothing to do with when leap years occur or how many have occurred since a given date. The MS date/time field already knows that.

It has to do, first, with the number of days per year, which must be an average, since the number of days is not the same for every year in our calendar: the first correction for this is leap years. Keep in mind that leap years fall in the years of US presidential elections. If there is a leap year once every four years you might think that the accurate number of days per year would be 365.25, since you add one day for every four years.

However, in the Gregorian calendar we use, adding a leap year every four years over-compensates for the true length of a year (now we are into the realm of astronomy and physics). Accordingly, once every 400 years, a year that would be expected to be a leap year is not. The years when leap year is skipped are those in which the first year of a century is evenly divisible by 400. So the first year of the 20th century, which was 1900, had no Feb 29, even though McKinley was elected President in that year.

The reason 1900 is the first year of the 20th century instead of, for example 1901, is another story, and it too has to do with the imposition of the rules of mathematics (mathematics demands a zero point in any ratio scale) on human life so as to make human life follow the rules of mathematics, which, of course, we invented. This process began in the 16th century, with the adoption of the Gregorian calendar in 1582, and was finalized in Europe during the 18th century. Many of us are are still catching up.

The only departure from this is that the Gregorian calendar, adopted by a Pope not a mathematician, does not in fact include a year of zero: it includes a year of one and a year of minus one--sounds like a programming issue to me. By default, 1 BC is the year of zero, and this of course has little to do with when Jesus may have been born. It is a left-over, historical artifact, stuffed into our more recent mathematical conception of the world.

MS date/time fields already know all of this. If you enter the date 2/29/1900 in a date/time field you will receive an error message: "your entry is invalid for the data type." If you try to enter the date 2/29/3000, the next year a leap year will be skipped, you will receive the same error message.

So the number of days since the DOB or any other date of interest needs to be divided by the correct number of days per year. That number is:

(400*365)+((400/4)-3)/400 = 365.2425.

There should be a 4,000 year rule too, because the 400 year rule will not be sufficient for more than, well, another millennium. But the Gregorian calendar does not include a 4,000 year rule. So in about 1,997.4167 years or so, the above calculation will be off by a day divided by 4000 years. The number of days in a year is also changing slowly as the solar system evolves, and further adjustments will be necessary eventually. Remember, there is no such thing as perfect measurement. Measurement is a human construct, which does not exist in the universe outside our minds.

The second major issue with age calculations is rounding, and this too has to do with the rules of mathematics.

When we speak in society, a person remains their current age in years until their next birthday. In speech, we are not 44.4 or 44.6, we are just 44 until we turn 45. Little children want to tell us more in order to make themselves look older (I am five and a half, said my son).

In mathematics, however, when we render a number with no decimal places it will be always be rounded up after 44.49999... . So if you include no decimal places, a person who is 44.49 will be rendered as 45, according to the rules of mathematics. In order to get the correct number of years according to the way we speak, you must include at least one decimal place.

However, if you do not specify how many decimal places you want, the default is 12, and this is the last issue with accurate age. Twelve decimal places is far too many for most purposes.

So here is the correct formula for 2 decimal places in a calculated field for a query:

AccurateAgeR:Round((Date()-[DOB])/365.2425,2)

Note that an age of 44.25 translates easily to 44 and 3 months, with a month equal to .08... years. It is cumbersome in most instances to try to include months themselves. When a report calls for "age," it is cleaner and easier to say 44.53, rather than 44 and 6.04 months. Tip: that is why we imposed the rules of mathematics on ourselves in the first place.

If you want to put the formula somewhere else other than a calculated field in a query, then the beginning, before the colon, needs to modified slightly.

David
 
I still contend that an accurate age can not be calculated from Date()-[DOB].

Assume that all clocks are accurate:

Date() is derived from a machine that has a known position so the Date returned is in four dimensions. Three of those dimensions, longitude, latitude and time are important (altitude may not be important).

DOB is one dimensional in that it only includes time but does not specify longitude or latitude. Both longitude and latitude are important because the International Date Line is not straight.

So the calculation makes an assumption that the DOB was at the same position as the machine that returned the Date() information. That assumption is almost always incorrect unless the person was born in the same time zone as the machine is operating.

A second assumption is that daylight saving was, and still is, enforced for both the birth of the person and the machine.

A third assumption is that both the place of birth and the place of operation of the machine have not had their calendars adjusted. Recently Samoa jumped forwards a day.

I can not see that a calculation can be said to be accurate if so much information is missing from the calculation.

Several years ago I had this discussion with a lieutenant in the New York police department. One of his replies, perhaps jokingly, was to the effect that “All of our police officers were born in room 101 down the hall.” By saying that he had applied position to time.

Another consequence is the aspect of law. If a person could be tried as a minor or as an adult it may very well be a subject of age. That situation would need to be governed by the relevant law applied to the specific case. I very much doubt if the accurate age calculation, as quoted, would suffice under all legal conditions.

Similarly, contracts may have a duration clause which could be in effect between two countries. An accurate calculation of duration would not be possible unless the position and time of both countries is specified. Again, this is a legal matter and the accurate age calculation, as quoted, would not suffice.

In a legal sense, one (perhaps two) days may need to be added in order to guarantee that a minium time has elapsed.


So this is the way it seems to me:-

Date()-[DOB] can not be known let alone be accurate. We are subtracting a one dimensional process from a four dimensional process leaving three dimensions hanging in a void.

It is the three dimensions of position which make it unknowable. (For convenience, altitudes may cancel.)

In database parlance:-
Date() = Time + longitude + latitude
[DOB] = Time + Null + Null

(Time + longitude + latitude) – (Time + Null + Null) = Null

The, so called, accurate age calculation is not only inaccurate it has actually become unknowable due to the implied Nulls.

This whole thing about Date Of Birth may very well arise from the non-compliance with 6NF. A DOB is an event, it happens in four dimensions, three spatial and one temporal. It is in 4D yet seldom is it specified as such. Little wonder that DOB becomes difficult when only one of its four dimensions is known.

Chris.
 
Last edited:
Dscudder

Did you test your theory?

Dob 1march 2011
Date of calculation 29 feb 2012

Result 1 but the result should be o years and 11 months for a human being who are the only "things" interested in seeing the result.

I do wish people would realise that IT is here to serve the people, it is ok to have your academic arguments but not at the expense of clarity of reply to a poster.

Brian
 
ChrisO

You know very well that Scientific experiements are either done under the same conditions in order to attempt to get the same result every time, or one or more conditions are changed to find the affect that that conditional change has made.

Naturally changing the time zone ( a change in a condition) is the same as changing the Date on the computer at the place of origin. I am calling the Place of Origin the same place as the place of birth.

If the Age Calculation of (Date() - DOB) is done on the original computer then a correct Age calculation will always produce the correct number of days. This is regardless of where that person may be on this planet.

Your arguement is of a legal nature which you are not qualified to comment on.
 
(400*365)+((400/4)-3)/400 = 365.2425.

This appears to work.

All you need to do now is to work out Months and Days. This was the original question.

EDIT

I did not test correctly.
If the Start Day is after the end Day then it fails.
Maybe more testing is required.
 
Last edited:
Rain.
I’m not saying that the answer you gave to Negger is unusable. It is as accurate as can be calculated with the information supplied. It also fills the need as requested.

Nor am I saying I have any special knowledge of the law in any particular case. But the law could hinge on a date of birth and the law should have some method to resolve the issue.

Let’s look at it this way. If I ask you “What time is it in the USA?” you could not give me an accurate answer because I have not specified where in the USA. So position becomes important to resolve the question of time. In fact, New York and Los Angeles could even be on a different date.

If the computer’s clock is adjusted to the same time zone as the place of birth of the person then the calculation is correct.


Brian.
It is a month, give or take a day :D , since Negger received the correct answer from Rain. I do not see the discussion in any way diminishing the value of what he has been given.

Chris.
 
19/2/2010 to 20/2/2011 returns 2 Years which is correct.
21/2/2010 to 20/2/2012 also returns 2 Years which is incorrect.

2 Years does not become correct until 21/2/2012 (In the second situation)

Trying to come up with a Mathematical Formula maybe a bit too much to ask.
 

Users who are viewing this thread

Back
Top Bottom