-1

I have a column with this format 20150228 and I need to change it to 02/28/2015. Is there any function in SQL to do it.

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
sp9
  • 755
  • 3
  • 11
  • 22

2 Answers2

3

You can use this assuming the date is stored as a varchar:

SELECT CONVERT(VARCHAR(50),CONVERT(DATE,'20150228',112),101)

It returns:

02/28/2015

Alex
  • 21,273
  • 10
  • 61
  • 73
0

Use FORMAT function:

SELECT CONVERT(NVARCHAR(10), GETDATE(), 101)
Giorgi Nakeuri
  • 35,155
  • 8
  • 47
  • 75