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+'))))
Bookmarks