Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / August 2005

Tip: Looking for answers? Try searching our database.

date formula in table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
alexasha - 16 Aug 2005 14:05 GMT
Hi,
I set up a form with age calculation using following formula
=DateDiff("yyyy",[DOB],Date())+Not (Format(Date(),"y")>=Format([DOB],"y"))
It works great, the only trouble is that those values are not exported to
age column in source table. I realize that I did not specify the source
table, but I do not know how. Basically, I want age to be calculated from DOB
in the form, and then also displayed in source table (age column). Please
help me to adjust this formula. Thanks
Klatuu - 16 Aug 2005 14:29 GMT
First problem is that you are wanting to put a calculated value in a table.  
There is almost never a reason to do that.  Why taking the processing time
and the disk space for something that has to be calculated each time it is
accessed anyway?
Next, I don't understand your formula at all.  What are you trying to
accomplish?

> Hi,
> I set up a form with age calculation using following formula
[quoted text clipped - 4 lines]
> in the form, and then also displayed in source table (age column). Please
> help me to adjust this formula. Thanks
alexasha - 16 Aug 2005 14:38 GMT
this formula calculates age from date of birth (another field). It works
fine. I am open to any alternatives, but I would like to have age value
somehow to be transfered from form (calculated field) to table. I will later
run queries and I will need this value.
Thanks

> First problem is that you are wanting to put a calculated value in a table.  
> There is almost never a reason to do that.  Why taking the processing time
[quoted text clipped - 11 lines]
> > in the form, and then also displayed in source table (age column). Please
> > help me to adjust this formula. Thanks
Klatuu - 16 Aug 2005 14:51 GMT
All you need to calculate age is:
=DateDiff("yyyy",[DOB],Date)
It is the other part I don't really get:
+Not (Format(Date(),"y")>=Format([DOB],"y"))

You don't need it.

You do not need to store the age in a table.  Any experienced database
developer and anything you read on database design will tell you not to store
calculated values.
Even for running a query, you don't need it.  You can include the
calculation in the query, for example,  If you want to get the age for a
person and you have the [DOB] field, then in the field row of the column in
the query builder where you want the age:

Age: DateDiff("yyyy",[DOB],Date)

Simple as that.

> this formula calculates age from date of birth (another field). It works
> fine. I am open to any alternatives, but I would like to have age value
[quoted text clipped - 17 lines]
> > > in the form, and then also displayed in source table (age column). Please
> > > help me to adjust this formula. Thanks
alexasha - 18 Aug 2005 14:12 GMT
=DateDiff("yyyy",[DOB],Date)
this formula does not work. I will stay with my old formula, that I found on
this forum, because it works. Thanks for your help.

> All you need to calculate age is:
> =DateDiff("yyyy",[DOB],Date)
[quoted text clipped - 36 lines]
> > > > in the form, and then also displayed in source table (age column). Please
> > > > help me to adjust this formula. Thanks
Klatuu - 18 Aug 2005 14:50 GMT
The formula does work.

> =DateDiff("yyyy",[DOB],Date)
> this formula does not work. I will stay with my old formula, that I found on
[quoted text clipped - 40 lines]
> > > > > in the form, and then also displayed in source table (age column). Please
> > > > > help me to adjust this formula. Thanks
Rick Brandt - 18 Aug 2005 15:07 GMT
> The formula does work.

The formula DateDiff("yyyy",[DOB],Date)  Will be wrong for all the days of
the current year before the persons birthday.  For example; if the DOB is
12/31/2004 it will indicate that they are one year old on 1/1/2005.  You
need to add an additional expression that takes this into account.

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.