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(),113)
result: 14 Jul 2011 09:23:57
Thanks a lot Largo
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)
A quick way to do it in sql server 2012 is as follows:
SELECT FORMAT(GETDATE() , 'dd/MM/yyyy HH:mm:ss')
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/
CONVERT(VARCHAR,GETDATE(),120)
精彩评论