title: Take the time from the datetime and convert it into seconds?
body: <p>I am running SQL Server 2005.  Technically I know how to take the time from a tsql datetime.</p>
  
  <pre><code>CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinuteSecond
  </code></pre>
  
  <p>The problem is that I have a datetime field and I need to essentially grab the time portion convert that to an integer specifically seconds.  Then I need to do a bunch of arithmetic on this integer that I won't discuss here.  I have searched on stackoverflow and haven't found a question that is specific to this question.  Any ideas?  I am really looking for best practices here, I am worried about creating a udf for this specific purpose as it completely throws the query optimizer out the window.</p>
  
  <p>I have seen this webpage so please don't paste this. :</p>
  
  <p><a href="http://forums.devx.com/showthread.php?171561-TSQL-Converting-HH-MM-SS-to-seconds">http://forums.devx.com/showthread.php?171561-TSQL-Converting-HH-MM-SS-to-seconds</a></p>