title: How do I check if the current time is between two times in SQL?
body: <p>This isn't working:</p>
  
  <pre><code>IF EXISTS (( SELECT  1
              FROM    dbo.SalesOrder )
     AND (GETDATE() BETWEEN '07:00:00' AND '16:00:00'))
     BEGIN
           PRINT 'yes!'
     END
  </code></pre>
  
  <p>I want to do:</p>
  
  <p>If something exists in the <code>SalesOrder</code> table AND the current time is between 7am and 4pm, then print 'YES'</p>
  
  <p>I'm assuming I might have to do a conversion there but I'm unsure on how to do it properly.</p>
  
  <p>Anyone care to give me a hand?</p>