title: SQL SELECT SUM BETWEEN 1 Year from now to start ot the year
body: <p>so I'm kinda stuck with a little query to get the SUM of the time period I want. So it already works but I want that it's automatically between 1 year from now and the beginning of the year.</p>
  <pre><code>SELECT SUM(N_EXCL), S_CUSTNO, S_CUSTNAME1, D_INVOICEDATE 
  from sao.INVOICE_P i 
  WHERE  D_INVOICEDATE &gt;   DATEADD (year, -1, getdate ())  
  AND D_INVOICEDATE &lt; DATEADD (month , -6 ,Getdate () ) 
  GROUP BY S_CUSTNO, S_CUSTNAME1, D_INVOICEDATE
  </code></pre>
  <p>Currently I would have to change the query every month but I try to find a way to avoid it.</p>
  <p>Ok. Maybe i wasn't clear enough. My problem is the -6 i have to write down. I want to switch it to a parameter that will automatically change up the date so that i get data from 01.01.2021 - 22.06.2021. So same date, but different year.</p>