SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

rockstar283
Yak Posting Veteran

90 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

webfred
Flowing Fount of Yak Knowledge

Germany
8764 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

rockstar283
Yak Posting Veteran

90 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  
 New 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.07 seconds. Powered By: Snitz Forums 2000