Thread: Average Age
View Single Post
  #8  
Old February 14th, 2010, 06:26 PM posted to microsoft.public.access.gettingstarted
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Average Age

Laura:

One other thing worth mentioning is that when you have a parameter in a query
to enter a date time value it’s a good idea to declare the parameter in the
query. This then avoids any possibility of a date being entered in short
date format, e.g. 14/2/2010, being misinterpreted as an arithmetical
expression. If this does happen it wouldn't raise an error as Access
implements the date/time data type as a 64 bit floating point number, the
integer part representing the days and the fractional part the times of day,
so it would be interpreted as the date time value which the number represents.
14/2/2010 as an arithmetical expression results in a number which represents
a date time value of 30 December 1899 00:05:01. This is because 30 December
1899 is 'day zero' in Access. You can see this by entering the following in
the debug window:

? Format(CDate(14/2/2010),"dd mmmm yyyy hh:nn:ss")

Parameters can be declared in query design view by selecting Parameters from
the Query menu (or whatever the equivalent is in Access 2007), or in SQL view
by adding a line to the beginning of the query. So for a parameter [Enter
Date] it would be:

PARAMETERS [Enter Date] DateTime;
SELECT etc

You can then be assured that however the user enters the date, provided it is
a legitimate date value, it will always be interpreted correctly.

Ken Sheridan
Stafford, England

Laura wrote:
Thanks for explaining, Ken - I know the feeling when applying to own
birthdate

I think the same principle applies if you're working out the age of a person
in terms of years.. you have to subtract a year, or something, or it works
out that you're a year older than you are and that's even worse!

Laura
London

Laura:

[quoted text clipped - 59 lines]
Thanks
Laura


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...arted/201002/1