title: Use something like LEAST in T-SQL on a datetime field
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1947753/getting-the-minimum-of-two-values-in-sql">Getting the minimum of two values in sql</a>  </p>
  </blockquote>
  
  
  
  <p>Okay what I Have a table with two datetime fields and I want to select the rows where the oldest date is equal to some date variable. I saw the LEAST function used somewhere but I can't use this in T-SQL</p>
  
  <p>I need something like this</p>
  
  <pre><code>SELECT LEAST(date1, date2) as theDate FROM theTable WHERE theDate = '2012-09-24'
  </code></pre>
  
  <p>but that will work in T-SQL. Also date1 or date2 can sometimes be null so that may be important to know.</p>