title: SQL Server: How to get current date time in YYYYMMDDHHMISSMSS
body: <p>I need the current date time in the format <code>YYYYMMDDHHMISSMIS</code> </p>
  
  <p>Example: </p>
  
  <pre><code>20110723233747607
  </code></pre>
  
  <p>By using the <code>CURRENT_TIMESTAMP</code> or <code>getdate()</code> functions, we can retrieve the current datetime into <code>2011-07-23 23:37:47.607</code> format. If I use <code>REPLACE</code> and <code>CONVERT</code> functions to remove the "-" and ":" characters, then I get the value into </p>
  
  <pre><code>Jul 23 2011 11:37PM
  </code></pre>
  
  <p>...format. But I need the current date time as <code>20110723233747607</code> to use it for my another purpose.</p>
  
  <p>My SQL query is: </p>
  
  <pre><code>SELECT REPLACE(CONVERT(VARCHAR(20), CURRENT_TIMESTAMP),'.','')
  </code></pre>
  
  <p>output: <code>Jul 23 2011 11:37PM</code></p>
  
  <p>So how can I get the current date time in my required format? Pls help.</p>