user3026641
user3026641

Reputation: 1

How to convert Date format in SQL Server?

Basically I want to convert date format from 'yyyy-mm-dd' to 'mm/dd/yyyy'.

Now here is the thing :

I used this to select current date.

Select GetDate();

Which shows the format as : 2015-07-10 14:29:30.227 Then :

Select CONVERT(VARCHAR, GETDATE(), 101)

It is working and displaying the result as : 07/10/2015

Now when I try to do this:

Select CONVERT(DATE, CAST('2015-06-15' AS DATE), 101)

And it does not show the desired result. Instead it shows the same format as : 2015-06-15

Any suggesstion would be of great help!!

Upvotes: 0

Views: 573

Answers (1)

MelgoV
MelgoV

Reputation: 656

Try this:

Select CONVERT(Varchar(10), CAST('2015-06-15' AS DATE), 101)

Upvotes: 3

Related Questions