A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How do I calculate ages in a simple table in Access?



 
 
Thread Tools Display Modes
  #1  
Old February 9th, 2006, 02:28 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default How do I calculate ages in a simple table in Access?

My table is simple. Field names are Last Name, First Name, Birthdate, Age. I
would like it to calculate the age when I enter the birthdate.
  #2  
Old February 9th, 2006, 02:32 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default How do I calculate ages in a simple table in Access?

You don't. You can't store a moving target in a table.

The correct method is to calculate age (as of the current date) in your
queries, forms, and reports.

The proper formula is:

DateDiff("yyyy",[Birthdate],Date())+(Format([Birthdate],"mmdd")Format(Date(),"mmdd"))



For more details, read the previous posts on "calculated fields" or
"calculating age".



--
Rick B



"Rodz" wrote in message
...
My table is simple. Field names are Last Name, First Name, Birthdate, Age.
I
would like it to calculate the age when I enter the birthdate.



  #3  
Old February 9th, 2006, 02:50 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default How do I calculate ages in a simple table in Access?

"Rodz" wrote in message
...
My table is simple. Field names are Last Name, First Name, Birthdate, Age.
I
would like it to calculate the age when I enter the birthdate.


You would calculate the age in a query at run-time. You would not usually
store a calculation so your Age field is redundant. Look up "calculated
fields" and "DateDiff" in the help - you'd need to find the difference
between the system date (using the "Date() function") and the stored date
and then express it in the format of your choice.

You'd also need to handle nulls in the DOB field so you don't get run-time
errors.

Regards,
Keith.
www.keithwilby.com


  #4  
Old February 9th, 2006, 05:04 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default How do I calculate ages in a simple table in Access?

As others have mentioned you USUALLY don't store the age. However, if you
need the age as of the date of entry, then you either need to store the date
of entry (and use it to calculate the age when you need the age) or you do
need to store the age.

The only way that Access will populate a field with a calculation is through
a form. Are you using a form for data entry? Normally, you should be.

The formula for calculating age (in years) is
DateDiff("yyyy", [Bdate], Date())+ Int( Format(Date(), "mmdd") Format(
[Bdate], "mmdd") )


"Rodz" wrote in message
...
My table is simple. Field names are Last Name, First Name, Birthdate, Age.
I
would like it to calculate the age when I enter the birthdate.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Query is not updatable - Doug Johnson via AccessMonster.com Running & Setting Up Queries 3 January 21st, 2006 12:36 AM
Multiple Options Group Patty Stoddard Using Forms 19 August 4th, 2005 02:30 PM
Many-to-many implementation problem Al Williams Database Design 15 April 29th, 2005 05:19 PM
Manual line break spaces on TOC or Table of tables Eric Page Layout 9 October 29th, 2004 04:42 PM
Table Wizard Does Not Set Relationship if Foreign Key and Primary Key Name Do Not Match Exactly in Case. HDW Database Design 3 October 16th, 2004 03:42 AM


All times are GMT +1. The time now is 10:13 PM.


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