Calculated Fields in a Table

K

KKallaur

If I would like to store a person's age as a column in a table, could
I calculate the value of the column based off of the Birthdate field?
I was trying to do this using the defaultvalue of a column, but I'm
thinking that is not the proper way to go about it. I am an oracle
programmer, where you can do this via a trigger....does Access have a
similar type of thing that I can use?

Thanks!
Katia
 
J

jayes

Hi,

Im not sure if you can set a default value to say datediff(... but you can
always base a query on that table with say
PersonsAge:Datediff("y",birthdate,now()) as a calculated field - sorry you
will have to look in help for exact syntax.
 
T

Tom van Stiphout

On Tue, 15 Apr 2008 17:45:20 -0700 (PDT), "(e-mail address removed)"

I understand you already have the Birthdate in a field (column) in a
table. Then why also store the age? Especially since it changes every
day for 1/365.25th of your records. If you store people from around
the world it actually changes every hour!
This is a PERFECT case for NOT storing calculated values in a table,
but rather compute them on the fly in a query. So any time you want to
get the age of a person, run a query to do the math.

Oracle is a fancy database, and perhaps like SQL Server 2005 it
supports computed columns. Access does not, so a query is your best
bet.

-Tom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top