Topics Search

Calculating an age with DateDiff

Calculating an age with DateDiff
Views: 0
I want to calculate an age on a given date each year. I have two fields: DateofBirth and Day01Date. I have built the following expression:

Age: DateDiff("y",tblRacerDetails!DateofBirth,tbluDay01Date!Day01Date)

But it is calculating the difference between the 2 years, so making people 1 year too old if they were born after Day01Date.

Previously I had used
Age_a: (DateDiff("y", tblRacerDetails!DateofBirth,#01/06/2008#))/365

and then

Age: Int([Age_a])

However this second method gives very strange values when I try using it based on a field rather than a single date
Sponsored Links:

More topics


Calculating someone's age from their birthday

Calculating someone's age from their birthday is not quite as simple as it might at first seem! Of course, you take the current year and subtract it from the year in which they were born. This will give you an accurate age in years - providing they have had their birthday this year. So, to be absolutely certain you need to decide if the day and month of their birthday has passed yet.

Calculating Age

I have been using a bit of code in a form to calculate the exact age from a Date of Birth control.

If IsNull(txt_DOB) Or IsNull(txt_Customer_ID) Then
Exit Sub
End If
txt_Age = DateDiff("yyyy", [DOB], Date) + (DateSerial(Year(Date), Month([DOB]), Day([DOB])) > Date)

It works fine on one computer, but for some unknown reason, when I run it on a different computer, I get this error (with Date highlighted)

Compile error:

Can't find object or library

automating age calcs

I have a table with fields for DOB and Age.

On the form I would like to automate the age based on the DOB. I have this formula that was in an unbound field and worked, but I cant get it to work on the bound field:


Additionally, I dont always have the DOB, so I want to be able to type an age in too, (however the priority should be to calc the age if the dob exists).

Please could you

calculating age (years and months) from birthdate

I am trying to build school database in which I would like to calculate the student's age from their date of birth (dd/mm/y). none of the suggestions I found on google yielded the desired outcome of age in years and months.

Age Calculation

I have several databases that I need to calculate the ages for. This specific database has the age calculation in the "consumers" table.

The code that I have is "Expr1: DateDiff("y",[Me].[BirthDate],DateAdd(6,"m",[Me].[CurrentDate]))". I have this to update the age "BeforeUpdate" in the form.

Query field has no data

Access 2007

I have a field 'Age' in a Form that automatically derives the age from another field in the same Form, 'Date of Birth.' When I create/run a query where I want to show the age relevant to each record the date of birth field is shown but the 'age' field has no data showing? I suspect it may be something to do with the fact that the age field is an automatic calculation ratherthan a numerical entry.

I would though very much like to perform the simple task of showing the age per field.

The field 'Age' in the form is a calculated field with the following in the Control Source of the Property Sheet:

=DateDiff("y",[Date of Birth],Now())+Int(Format(Now(),"mmdd")

Calculating length of stay in form using Datediff

I'm designing a form and I want to calculate how long our hotel tenants stay. So I have the form open and I am in the property sheet under the data tab. I am using the expression builder, and I see DateDiff has this format: DateDiff (interval, date1, date2, firstweekday, firstweek)

I put in this: DateDiff("d",([End Date],Date())-[Start Date])

I'm getting a wrong number of arguments error. I was also getting another error last night related to the "d" portion of the equation. Obviously I am pretty new and unsophisticated at this stuff so I thought I would check with the experts here for some

How to validate dynamically generated text box

here is the problem:
I have two text boxes, DOB (Date of Birth) and Age.
Age is not gotten from the table, instead it uses this formula in the Control Source: "=DateDiff("yyyy",[DOB],Date())" in order to calculate the age in years.
This works beautifully, except I need to validate the Age box using "<=14 And >=19" but this validation is ignored because the information is generated dynamically.

Can anyone please suggest a way of making this work, or possibly another way of approaching the problem.

I don't have very much experience with Access, so please be gentle

Calculating Age from DOB

In the form I have designed, I want the Age to be calculated and printed side-by-side when the DOB is entered.

How shall I go about it

Calculating Age from DOB

In the form I have designed, I want the Age to be calculated and printed side-by-side when the DOB is entered.

How shall I go about it?