title: Convert datetime to yyyymmddhhmmss in sql server
body: <p>I need to calculate the local time from yyyymmddhhmmss and return it as yyyymmddhhmmss. I have tried the below, it is working but I am not able to get rid of the month name.</p>
  
  <pre><code>Declare  @VarCharDate  varchar(max)
  Declare  @VarCharDate1 varchar(max)
  Declare  @VarCharDate2 varchar(max)
  
  --Declare
  set  @VarCharDate = '20131020215735' --- YYYYMMDDHHMMSS
  
  --Convert
  set @VarCharDate1 =(select SUBSTRING(@VarCharDate,0,5) + '/' + SUBSTRING(@VarCharDate,5,2)  + '/' + SUBSTRING(@VarCharDate,7,2) +  ' ' + SUBSTRING(@VarCharDate,9,2) +':'+SUBSTRING(@VarCharDate,11,2) +':' + RIGHT(@VarCharDate,2))
  select @VarCharDate1
  
  --Convert to Date and Add offset
  set @VarCharDate2 =  DATEADD(HOUR,DateDiff(HOUR, GETUTCDATE(),GETDATE()),CONVERT(DATETIME,@VarCharDate1,20))
  select @VarCharDate2   
  
  
  -- Now we need to revert it to YYYYMMDDhhmmss
  --Tried this but month name still coming
  Select convert(datetime, @VarCharDate2, 120)
  </code></pre>