Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 swap characters in a string

Author  Topic 

rockstar283
Yak Posting Veteran

96 Posts

Posted - 2013-02-27 : 13:13:12
I have a table with a column named 'from_date' containing date string in which first two letters denote date and 4th,5th letter denotes month..e.g. '09/01/2013'

I need to change this string to show month first and then the date..e.g. '01/09/2013'

Can anyone tell me how to do this??

Thanks in advance

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-02-27 : 13:26:28
If possible turn your column into DATE format to store dates and do the needed formatting in your front end.

If that isn't possible try this:
update table
set from_date=convert(varchar(10),convert(date,from_date,103),101)

But after this convert did happen you can't do it a second time - you know.


Too old to Rock'n'Roll too young to die.
Go to Top of Page

rockstar283
Yak Posting Veteran

96 Posts

Posted - 2013-02-27 : 13:32:56
Thank you so so much..That worked like a charm :)
Go to Top of Page
   

- Advertisement -