SQLTeam.com | Weblogs | Forums

Stipping out characters


I have a field with a date in it, but it is 2015-06-05

How do i change it to 20150605



If its a string field: replace(yourfield,'-','')
If its a date field: convert(varchar(8),yourfield,112)


If this is for display purposes, you should be doing this conversion in the application and not in SQL.