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
 General SQL Server Forums
 New to SQL Server Programming
 (Solved)Date formatting question from Substring
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

FightingTiger
Starting Member

USA
23 Posts

Posted - 07/09/2013 :  09:39:01  Show Profile  Reply with Quote
'17686568 - Bill Statement - 11/16/2006 - Stm. Date - 10/27/2006'

Above is the data string that I am trying to pull the information from. Here is the function I'm currently using:

cast(substring(c.itemname,charindex('Bill Statement - ',c.itemname)+18,10) as varchar)
...which gives me what i want most of the time, but beacuse the date is not equally formatted through out the database and the date can look like 5/4/2012 and using the above formula it will show up as 5/4/2012 -

So my question is how can i trim off the dash part when the data shows up like 5/4/2012 - ?

Edited by - FightingTiger on 07/09/2013 13:03:14

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1050 Posts

Posted - 07/09/2013 :  10:12:26  Show Profile  Reply with Quote
use replace function e.g.

Replace(<yours code>,'-','')

Cheers
MIK
Go to Top of Page

FightingTiger
Starting Member

USA
23 Posts

Posted - 07/09/2013 :  10:20:46  Show Profile  Reply with Quote
Thank you so much, after seraching around i thought replace might work but wasnt sure how to use it.
Go to Top of Page

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1050 Posts

Posted - 07/09/2013 :  10:40:33  Show Profile  Reply with Quote
Welcome!~

Cheers
MIK
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.06 seconds. Powered By: Snitz Forums 2000