Search code examples
sql-serversql-server-2005date-formatting

Return date as ddmmyyyy in SQL Server


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


Solution

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

    SELECT REPLACE(CONVERT(CHAR(10), [MyDateTime], 103), '/', '')