format date 2017-08-01 to 01-08-2017

I have a date that comes in like this
2017-08-01

and I want to make it into this
01-08-2017

what is the best method to do this?
vbnetcoderAsked:
Who is Participating?
 
_agx_Commented:
Best is relative, but assuming it's a DATE type, one way is using CONVERT with the appropriate style:

SELECT  CONVERT(varchar, @yourDateValue, 105)  --- produces 'dd-mm-yyyy'

For newer versions you can also use FORMAT()

           SELECT FORMAT(@yourDateValue, 'dd-MM-yyyy')
0
 
vbnetcoderAuthor Commented:
ty
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.