PDA

View Full Version : Access Querry - selecting ages 18+ from DOB



Iain Palmer
27-03-2011, 04:57 PM
Hey all

I'm greating a database using MS Access 2007, where I need to select everyone with an age of 18+ and display ages.

I currenly are using the following to display ages in the querry and assated report

Age: DateDiff( "yyyy", [DOB], Date() ) + ( Date() < DateSerial( Year( Date() ), Month([DOB]), Day([DOB]) ) )

How do I get the querry to display those aged 18 and over??

Thanks

inphinity
27-03-2011, 05:30 PM
Select <fields> from <tables> where DateDiff("yyyy", <DOB Field>, Date()) > 18;

Paul.Cov
28-03-2011, 08:55 AM
Make that >=18 in the above post.

So in your query view, look a few lines down and you'll find the criteri field. Put >=18 in the cell where you Age column intersects the Criteria line.