Subtracting Dates

J

jay_2882

Hi,

I'm using an access query to attmept to see if somebody meets a specific age
requierement. I need it accurate down to the present day. I tried subtracting
a date/time field and the Now() function and then invoking the year()
function on the whole thng. This gave me dates in the 1920s. I'm looking for
an age. Any help would be appreciated. Thanks,
jay_2882
 
J

John W. Vinson

Hi,

I'm using an access query to attmept to see if somebody meets a specific age
requierement. I need it accurate down to the present day. I tried subtracting
a date/time field and the Now() function and then invoking the year()
function on the whole thng. This gave me dates in the 1920s. I'm looking for
an age. Any help would be appreciated. Thanks,
jay_2882

A Date/Time value is stored as a floating point number, a count of days and
fractions of a day since midnight, December 30, 1899. Your expression will
give a peculiar result because you're mixing metaphors, expecting a
subtraction to give you a valid date value...!

See
http://www.mvps.org/access/datetime/date0001.htm
or for an age in years, use an expression

Age: DateDiff("yyyy", [DateOfBirth], Date()) - IIF(Format([DOB], "mmdd") >
Format(Date(), "mmdd"), 1, 0)

The IIF expression corrects the age for those people who have a birthday
coming up later this year.

John W. Vinson [MVP]
 

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