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
 General SQL Server Forums
 New to SQL Server Programming
 (Solved)Date formatting question from Substring

Author  Topic 

FightingTiger
Starting Member

23 Posts

Posted - 2013-07-09 : 09:39:01
'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 - ?

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-07-09 : 10:12:26
use replace function e.g.

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

Cheers
MIK
Go to Top of Page

FightingTiger
Starting Member

23 Posts

Posted - 2013-07-09 : 10:20:46
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
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-07-09 : 10:40:33
Welcome!~

Cheers
MIK
Go to Top of Page
   

- Advertisement -