-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
  • 704,970
  • 168
  • 1,303
  • 1,425
sp9
  • 737
  • 3
  • 10
  • 20

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
  • 20,287
  • 10
  • 59
  • 69
0

Use FORMAT function:

SELECT CONVERT(NVARCHAR(10), GETDATE(), 101)
Giorgi Nakeuri
  • 34,370
  • 8
  • 37
  • 69