calculating age.

ckitzman

Registered User.
Local time
Today, 05:31
Joined
Sep 15, 2006
Messages
13
age: DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")<Format([DOB],"mmdd"))

Dob is stored yyyyddmm

I thought this above function looks ok. When I run it, I get a data type mismatch in criteria expression.

What am I missing?
Any help would be appreciated.
Thanks
 
DOB has to be a date/time field, you have a string... this is causing the problem

Try using the function DateSerial to transform the string to a date and ... it should work
 
namliam said:
DOB has to be a date/time field, you have a string... this is causing the problem

Try using the function DateSerial to transform the string to a date and ... it should work

Like this?:
DOB: Mid([date_of_birth],5,2) & "/" & Mid([date_of_birth],7,2) & "/" & Mid([date_of_birth],1,4)

I have this in the same query. I'm not familiar with DateSerial, sorry.
 
Have you looked up DateSerial in VBA Help to see how it works?
 
RuralGuy said:
Have you looked up DateSerial in VBA Help to see how it works?[/QUOTE

obviously not. i don't know VB, just a rookie trying to get rid of a pesky error.
Thanks
 
Well don't take this wrong but do you plan to be a rookie forever? These forums are usually to help people help themselves. Do you need help getting to VBA Help?
 
RuralGuy said:
Well don't take this wrong but do you plan to be a rookie forever? These forums are usually to help people help themselves. Do you need help getting to VBA Help?
naw, i got it. thanks. I was trying to do too many things in one query. I separated the steps out and it's working fine now. Thanks
 
Last edited:

Users who are viewing this thread

Back
Top Bottom