title: how to count elements in google spreadsheets matching a certain date range
body: <p>I have some data in columns with a timestamp in the first column and data columns.</p>
  
  <pre><code>A             B         C         D
  +++++++++++++++++++++++++++++++++++
  20.5.2011     1         2         5
  18.5.2011     3         5         4
  12.5.2013     4         7         5
  </code></pre>
  
  <p>I am able to successfully filter columndata based on the timestamp with this google spreadsheets formula. The below returns a sum of all integers in column B if there is a corresponding 2011 timestamp. </p>
  
  <pre><code>=ArrayFormula(SUMIF(TEXT($A:$A;"yyyy");year(today())-1;$B:$B))
  </code></pre>
  
  <p>the above sums up the values 1 and 3 from column b and returns 4</p>
  
  <p>The question is, how would I calculate the average for the above values 1 and 3 resulting in 2? My current approach is to divide the above formula by the count() of items that match the date criterion but I cannot get it to work.</p>
  
  <pre><code>=ArrayFormula(SUMIF(TEXT($A:$A;"yyyy");year(today())-1;$B:$B))/WFORMULA FOR THE DIVISOR
  </code></pre>
  
  <p>Any ideas?</p>