how to format getdate into YYYYMMDDHHmmSS

后端 未结 7 1507
春和景丽
春和景丽 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:34

    Another option!

    SELECT CONVERT(nvarchar(8), GETDATE(),112) + 
       CONVERT(nvarchar(2),DATEPART(HH,GETDATE())) + 
       CONVERT(nvarchar(2),DATEPART(MI,GETDATE())) + 
       CONVERT(nvarchar(2),DATEPART(SS,GETDATE()));
    

提交回复
热议问题