How to Convert datetime value to yyyymmddhhmmss in SQL server?

vignesh picture vignesh · Apr 17, 2014 · Viewed 107.8k times · Source

How to convert datetime value to yyyymmddhhmmss?

for example From 2014-04-17 13:55:12

To 20140417135512

Answer

JPT picture JPT · Apr 14, 2015

Since SQL Server Version 2012 you can use:

SELECT format(getdate(),'yyyyMMddHHmmssffff')