In SQL Server how do I format getdate()
output into YYYYMMDDHHmmSS
where HH
is 24 hour format?
I\'ve got the YYYYMMDD
Close but not exactly what you are asking for:
select CONVERT(varchar, GETDATE(), 126)
e.g.
2011-09-23T12:18:24.837
(yyyy-mm-ddThh:mi:ss.mmm (no spaces), ISO8601 without timezone)
Ref: CAST and CONVERT
There is no way to specify a custom format with CONVERT()
. The other option is to perform string manipulation to create in the format you desire.