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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 swap characters in a string
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

96 Posts

Posted - 02/27/2013 :  13:13:12  Show Profile  Reply with Quote
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

Edited by - rockstar283 on 02/27/2013 13:19:26

Flowing Fount of Yak Knowledge

8781 Posts

Posted - 02/27/2013 :  13:26:28  Show Profile  Visit webfred's Homepage  Reply with Quote
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

Yak Posting Veteran

96 Posts

Posted - 02/27/2013 :  13:32:56  Show Profile  Reply with Quote
Thank you so so much..That worked like a charm :)
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000