I have a spreadsheet where I am trying to return the average age of a patient seen at a particular office. I need to calculate their age by subtracting the DateSeen (Column A) by their DOB (Column C) and then return the results conditionally based on whether they are seen at office 0 or office 1 (Column B). I can use the embed subtraction into an AVERAGE function, but when I attempt to put it into an AVERAGEIF function, it will not result. Any help would be appreciated.

DateSeen Office DOB ***
8/15/12 0 9/16/39 Male
8/22/12 0 4/20/28 Male
8/22/12 0 3/4/22 Female
9/5/12 1 6/7/26 Male
9/19/12 0 8/5/31 Female
12/19/12 1 5/24/31 Male
1/9/13 1 4/8/29 Male
1/16/13 0 2/1/46 Male