title: Using ISNULL and DATEDIFF of dates to days and sum the result in select
body: <p>I would like to do a couple of iterations in the query.
  I need the number of days as the result.
  I have 2 types of dates (AE dates) and (IPDates). Each of them has start date and an end date
  (AEStartDateTime,AEENDDateTime) and (IPStartDate , IPEndDate)</p>
  
  <p>I would like to select there from the table and substract both pairs each to get 2 number of days
  As the result are 2 values in days format, i want to sum them.
  The main condition is these column's can be null</p>
  
  <pre><code>SELECT
  ((ISNULL(DATEDIFF(DAY , AEStartDateTime , AEEndDateTime)),0) 
  + (ISNULL(DATEDIFF(DAY , IPStartDate , IPEndDate)),0)) 
  as 'IPBedDays'
  FROM Details
  </code></pre>
  
  <p>This does not work. Can you help</p>