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
SQL Date Data Types DATE - format YYYY-MM-DD. DATETIME - format: YYYY-MM-DD HH:MI:SS. TIMESTAMP - format: YYYY-MM-DD HH:MI:SS. YEAR - format YYYY or YY.
By using format code as 111 we can get datetime in “YYYY/MM/DD” format. By using format code as 112 we can get datetime in “YYYYMMDD” format. By using format code as 113 we can get datetime in “DD MMM YYYY HH:mm:ss: fff” format. By using format code as 114 we can get datetime in “HH:mm:ss: fff” format.
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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With