In this article I will explain with an example, how to convert (select) Date in dd/MM/yyyy format in SQL Server.
This article will illustrate how to use Stored Procedures for converting Dates in dd/MM/yyyy format.
Database
I have made use of the following table Medicines with the schema as follows.
Note: You can download the database table SQL by clicking the download link below.
Select Date in dd/MM/yyyy format using Stored Procedure in SQL Server
Inside the Select_Medicine Stored Procedure, the Date column values are converted into dd/MM/yyyy format using the CONVERT function and passing value 103 for the third parameter.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE Select_Medicine
@MedicineId INT
AS
BEGIN
SET NOCOUNT ON;
SELECT [Name]
,CONVERT(VARCHAR(10), [ManufacturingDate], 103) [ManufacturingDate]
,CONVERT(VARCHAR(10), [ExpiryDate], 103) [ExpiryDate]
FROM Medicines
WHERE MedicineId = @MedicineId
END
GO
Output