I want to display Date fields in SQL Query Results as DD-MM-YYYY Format. In table it is vice versa. When I try with below query it does not works.
SQL Query Link: (Tables can be retrieved by clicking Employees and Orders links under “SQLSERVER Database:” section)
https://www.w3schools.com/sql/trysqlserver.asp?filename=trysql_func_sqlserver_convert3
SQL Query I used:
x
select
a.EmployeeID,
a.BirthDate CONVERT(datetime, 'DD-MM-YYYY'),
b.OrderID,
b.OrderDate CONVERT(datetime, 'DD-MM-YYYY')
from
Employees a, Orders b
where
a.EmployeeID = b.EmployeeID;
Advertisement
Answer
You can use the following query;
select
a.EmployeeID,
CONVERT(varchar, a.BirthDate, 105) as BirthDate,
b.OrderID,
CONVERT(varchar,b.OrderDate ,105) as OrderDate
from
Employees a, Orders b
where
a.EmployeeID = b.EmployeeID