title: T-SQL - Convert datetime to unseparated ISO value
body: <p>I'm trying to convert the following <code>DATETIME</code> into ISO format:</p>
  
  <pre><code>-- Today's Date
  2018-04-16 2:04PM
  </code></pre>
  
  <p>I plan on parsing this into a <code>char</code> value as <code>NVARCHAR</code> so that I can concatenate it as part of a string.</p>
  
  <p>Desired result should be:</p>
  
  <pre><code>-- Date and time unseparated
  20180416140422
  </code></pre>
  
  <p>After some research I discovered <a href="https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-2017" rel="nofollow noreferrer">here</a> that </p>
  
  <pre><code>CONVERT(datetime, GETDATE(), 112)
  </code></pre>
  
  <p>using the 112 format code should get me the format I want but somehow I get the following sample output:</p>
  
  <pre><code>--Formatted using 112 format
  Apr 16 2018 2:04PM
  </code></pre>
  
  <p>Why is this? I simply want to format the <code>DATETIME</code> object unseparated. </p>
  
  <p>Also how would I do this with or without the time tagged onto the end?</p>
  
  <p>Using SQL Server 2008R2</p>