-4

how can I change the Date format form YYYY-MM-DD to DD-MM-YYYY ? I tried this command:

select CONVERT(varchar(10), @date, 101)

but it did not work. Can anyone help me?

Thanks!

4 Answers4

1

use format

declare @d date='2018-11-19';

select format(@d,'dd-MM-yyyy')

Fiddle

date
19-11-2018
Zaynul Abadin Tuhin
  • 31,407
  • 5
  • 33
  • 63
1
DECLARE @Param1 DATE
SET @Param1 = '2018-01-31'  -- YYYY-MM-DD

SELECT CONVERT(VARCHAR(10),@Param1,105) AS DesiredDate  -- DD-MM-YYYY
Fahmi
  • 37,315
  • 5
  • 22
  • 31
0

You can try this SQL:

Select CONVERT(varchar(100), GETDATE(), 105) as 'DD-MM-YYYY'
Fahmi
  • 37,315
  • 5
  • 22
  • 31
Justin
  • 1
  • 2
0

You can try below

DEMO

select CONVERT (varchar(10), getdate(), 103) AS [DD/MM/YYYY]

OUTPUT:

DD/MM/YYYY
19/11/2018
Fahmi
  • 37,315
  • 5
  • 22
  • 31