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

Thanks

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

2 Likes

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