#  Other Applications & Softwares  > Access Tables & Databases >  >  Age bracket not working!

## akhlaq768

I have created a query to work the age bracket from the Date of Birth to date of visit, both fields are date and time

below are some example of this.

Note that the age bracket of 0-16 isn't a correct result. what is wrong with the query?


Date_Of_Birth	DateofVisit	Age Bracket	   
06-Oct-1907	09-May-2008	0 - 16	   
06-Oct-1907	12-May-2008	0 - 16	   
06-Oct-1907	13-May-2008	0 - 16	   
06-Oct-1907	06-May-2008	0 - 16	   
06-Oct-1907	03-May-2008	0 - 16	   
06-Oct-1907	20-May-2008	0 - 16	   
06-Oct-1907	16-May-2008	0 - 16	   
06-Oct-1907	19-May-2008	0 - 16	   
06-Oct-1907	08-May-2008	0 - 16	   
06-Oct-1907	07-May-2008	0 - 16	   
06-Oct-1907	14-May-2008	0 - 16	   
06-Oct-1907	15-May-2008	0 - 16	   
06-Oct-1907	06-May-2008	0 - 16	   
06-Oct-1907	13-May-2008	0 - 16	 


Age Bracket: 
IIf(([DateofVisit]-([Date_Of_Birth]))/365<='16','0 - 16',
IIf(([DateofVisit]-([Date_Of_Birth]))/365 Between '17' And '30','17 - 30',
IIf(([DateofVisit]-([Date_Of_Birth]))/365 Between '31' And '65','31 - 65',
IIf(([DateofVisit]-([Date_Of_Birth]))/365 Between '66' And '75','66 - 74','75+'))))

----------


## GuruWannaB

Umm...question.  I noticed on all your dates of birth...the year is 1907 - making everyone 100+ years old.  

Can you upload a copy of worksheet.  It might help with identifying the specific issue.

----------


## GuruWannaB

Here is a formula for C1 (with A1 being Date of Birth, and B1 being your visit date)




```
Please Login or Register  to view this content.
```


This will check to see if there is a date of birth, if not...output is a blank...same if there is not a visit date.

Hope this helps...otherwise, upload a copy of the file.  I'll be on tommorrow to see if you still don't have it resolved.

----------


## akhlaq768

cheers will give it a go

----------


## akhlaq768

as requested i have attached the database containing the raw table and the query im using to work out the age bracket correctly, as im getting errors for any people in the 100, they all turn to "0-16"

----------


## akhlaq768

got it sorted, 



thanks mate

----------

