?
Solved

MS Access age less than 18 years

Posted on 2011-10-10
9
Medium Priority
?
376 Views
Last Modified: 2012-05-12
I have a  date of birth field that is a string YYYYMMDD.  We want persons that are 18 years old or younger as of today's date.  What syntax would I use in an Access query for a report?
0
Comment
Question by:LindaOKSTATE
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 1000 total points
ID: 36945848
SELECT *
FROM SomeTable
WHERE DOB >= Format(DateAdd("yyyy", -18, Date()), "yyyymmdd")
0
 
LVL 75
ID: 36945869
Ahh ... what happens if the DOB is tomorrow 20111011 ?

0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 36946064
You're projecting future births?

:)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75
ID: 36946067
sorry ... I meant say:

To be 18 Today, DOB would be 10-10-1993

What about Tomorrow thru 12-31-2011 ?

I think your age calc shows still shows 18, which is incorrect.

mx
0
 

Author Comment

by:LindaOKSTATE
ID: 36946105
Not sure what you mean?
0
 
LVL 75
ID: 36946112
Well ... age calcs are tricky ... is what I'm saying.

mx
0
 

Author Comment

by:LindaOKSTATE
ID: 36946148
I guess that person would not show up until the next report.  What else could you do?
0
 
LVL 75
ID: 36946160
Patrick ... ignore my comments.  I still have stated it correct.  The age stuff fries my brain every time.

mx
0
 
LVL 52

Expert Comment

by:Gustav Brock
ID: 36947871
I cannot see how it should fail. DateAdd is always right.

/gustav
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question