[sql-server-2008-r2] How to Convert datetime value to yyyymmddhhmmss in SQL server?

How to convert datetime value to yyyymmddhhmmss?

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

To 20140417135512

This question is related to sql-server-2008-r2 datetime-format

The answer is

Since SQL Server Version 2012 you can use:

SELECT format(getdate(),'yyyyMMddHHmmssffff')

Similar questions with sql-server-2008-r2 tag:

Similar questions with datetime-format tag: