SQL Server Format Date DD.MM.YYYY HH:MM:SS

前端 未结 4 1376
南笙
南笙 2020-12-11 01:43

How can I get a date like \'dd.mm.yyyy HH:MM:SS\' I tried the following but it\'s not exactly what I\'m looking for...

select convert(varchar(20),getdate(),1         


        
相关标签:
4条回答
  • 2020-12-11 02:09

    See http://msdn.microsoft.com/en-us/library/ms187928.aspx

    You can concatenate it:

    SELECT CONVERT(VARCHAR(10), GETDATE(), 104) + ' ' + CONVERT(VARCHAR(8), GETDATE(), 108)
    
    0 讨论(0)
  • 2020-12-11 02:14

    A quick way to do it in sql server 2012 is as follows:

    SELECT FORMAT(GETDATE() , 'dd/MM/yyyy HH:mm:ss')
    
    0 讨论(0)
  • 2020-12-11 02:19

    You can learn datetime formatting in sql server here

    http://www.sql-server-helper.com/tips/date-formats.aspx

    http://yrbyogi.wordpress.com/2009/11/16/date-and-time-types-in-sql-server/

    0 讨论(0)
  • 2020-12-11 02:27
    CONVERT(VARCHAR,GETDATE(),120)
    
    0 讨论(0)
提交回复
热议问题