title: SQL Check for Null Date and then Case Switch
body: <p>I have a data result that I want to filter by two different dates.</p>
  
  <p>The below is working except when completion_date is null. If it is null I want to use a different field called created_date.</p>
  
  <pre><code>string strSQL = string.Format(@"select * from my_table 
  
              where user_Id = {0}
  
              AND [completion_date] between {1} AND {2}
  
              order by completion_status  desc, [completion_date] asc"
              , userId, dateStart, dateEnd, visibilityIndicator);
  </code></pre>
  
  <p>Perhaps something like this:</p>
  
  <pre><code>string strSQL = string.Format(@"select * from my_table                                                   
  where user_Id = {0}
  
  
  CASE completion_date 
       WHEN is null THEN [completion_date] between {1} AND {2}
       ELSE [created_date] between {1} AND {2}
  
  END 
  
  AND                       
              order by completion_status  desc, [completion_date] asc"
              , userId, dateStart, dateEnd, visibilityIndicator);
  </code></pre>
  
  <p>What is the best way to check for that null value and then switch to created_date?</p>