title: SQL minimum date value after today's date Now()
body: <p>I am writing a query and am having trouble filtering data as I would like.  In the table, there is a date field and an ItemCode field. I would like to return one record per ItemCode with the earliest date that is after today.  </p>
  
  <p>If today is 6/6/2017 and my data looks like:</p>
  
  <pre><code>ItemCode     Date  
  1            6/1/2017  
  1            6/7/2017  
  1            6/10/2017  
  2            6/2/2017  
  2            6/8/2017  
  2            6/15/2017  
  </code></pre>
  
  <p>I would want the result to be </p>
  
  <pre><code>ItemCode     Date  
  1            6/7/2017  
  2            6/8/2017
  </code></pre>
  
  <p>My query so far is:</p>
  
  <pre><code>SELECT PO_PurchaseOrderDetail.ItemCode, Min(PO_PurchaseOrderDetail.RequiredDate) AS NextPO
  FROM PO_PurchaseOrderDetail
  GROUP BY PO_PurchaseOrderDetail.ItemCode
  HAVING (((Min(PO_PurchaseOrderDetail.RequiredDate))&gt;=Now()));
  </code></pre>
  
  <p>The problem is that the Min function fires first and grabs the earliest dates per ItemCode, which are before today.  Then the >=Now() is evaluated and because the min dates are before today, the query returns nothing.</p>
  
  <p>I've tried putting the >=Now() inside the min function in the HAVING part of the query but it does not change the result. </p>
  
  <p>My structure is wrong and I would appreciate any advice. Thanks!</p>