title: How to Calculate Days Gap Between End Date and Start Date in SQL
body: <p>I have </p>
  
  <p>CustID  Contract start  contract ends 
  100     2013-09-30       2013-12-31<br>
  100     2014-02-28       2014-12-31</p>
  
  <p>The calculation should give me the Gaps in days between contracts </p>
  
  <p>I am trying to do the below which gives me the Contract duration:</p>
  
  <p>SELECT CustID
      , StartDt
      , EndDt
      , FIRST_VALUE(DateDiff(DAY, StartDt, EndDt)) OVER (PARTITION BY CustID ORDER BY CustID </p>
  
  <pre><code>ROWS BETWEEN 0 PRECEDING AND 1 FOLLOWING) C
  </code></pre>
  
  <p>FROM tblContracts</p>
  
  <p>However, I need the calculation between the end date of the last contract and the start date of the second contract </p>
  
  <p>Any Suggestions would be really helpfull</p>