I'm using access 2003 and have a query based on a table
I have the kid's dob as a field and I want to calculate today's age...I've done that with today()-[dob]
But it comes up in a very large number and when I divide manually by 365 it's correct
When I do it in the program it comes up in time format
Any suggestions?
I'm not quite sure what you meant by that last line, "When I do it in the program it comes up in time format." There are a couple links in my signature that explain Date/Time data types in Access. There is a function called DATEDIFF that will probably serve you better than TODAY() - [dob]. You may find an overview at the following site:
You just need to a bit careful with that DateDiff function. If you specify difference in years ('yyyy') it will only work on the year part of each date, e.g. if today is 20 May 2007 and [dob] is 20 May 2000 it will return an age of 7 years (correct), but if today is 20 May 2007 and [dob] is any date between 21 May 2000 and 31 Dec 2000 it will still return an age of 7 years (incorrect of course).
I have a VBA function I can let you have which you can use in the query (it also takes account of a birth date of 29th February in a leap year) but I need to know (i) is the data type for your [dob] field 'date' ('date/time') or is it a text field? and (ii) what format do you have for the date in the [dob] field?
Deej
Status
Not open for further replies.
You have insufficient privileges to reply here.
Related Threads
?
?
?
?
?
Tech Support Guy
9.9M posts
859.7K members
Since 1998
A forum community dedicated to tech experts and enthusiasts. Come join the discussion about articles, computer security, Mac, Microsoft, Linux, hardware, networking, gaming, reviews, accessories, and more!