how to format getdate into YYYYMMDDHHmmSS

后端 未结 7 1503
春和景丽
春和景丽 2021-02-19 04:50

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

I\'ve got the YYYYMMDD

相关标签:
7条回答
  • 2021-02-19 05:42

    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.

    0 讨论(0)
提交回复
热议问题