Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return date as ddmmyyyy in SQL Server

Tags:

I need the date as ddmmyyyy without any spacers.

How can I do this?

I can get yyyymmdd using CONVERT(VARCHAR, [MyDateTime], 112)

But I need the reverse of this.

SQL Server 2008

like image 887
Matt Avatar asked Jul 21 '11 01:07

Matt


1 Answers

CONVERT style 103 is dd/mm/yyyy. Then use the REPLACE function to eliminate the slashes.

SELECT REPLACE(CONVERT(CHAR(10), [MyDateTime], 103), '/', '') 
like image 52
Joe Stefanelli Avatar answered Oct 20 '22 09:10

Joe Stefanelli