Search code examples
sql-server-2005getdate

how to format getdate into YYYYMMDDHHmmSS


In SQL Server how do I format getdate() output into YYYYMMDDHHmmSS where HH is 24 hour format?

I've got the YYYYMMDD done with

select CONVERT(varchar,GETDATE(),112)

but that is as far as I got.

Thanks.


Solution

  • select replace(
           replace(
           replace(convert(varchar(19), getdate(), 126),
           '-',''),
           'T',''),
           ':','')