title: SQL query that displays the current date and count of days between two specific dates
body: <p>I am trying to write a SQL query that shows the count of the days and date depending upon the financial period it falls in. The financial period starts 5 days before the month end eg march 27th to 26th April</p>
  
  <p>For the above mentioned period if the day is 29th march, the count of the day should be 3 and the date should be 2020-04. The date should adjust depending upon the period it falls in.</p>
  
  <p>I tried to adress the second part of this query by writing the below script but it does not bring any result</p>
  
  <pre><code>declare @date datetime
  set @date = getdate()
  SELECT format (date,'yyyy-MM-dd') as date
  
  where @date
  
  between dateadd(day,-5,EOMONTH(getdate(),-1)) and dateadd(day,-5,EOMONTH(getdate()))
  </code></pre>