Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strip word off end of field and convert

Status
Not open for further replies.

Ofina

Technical User
Feb 25, 2004
156
US
I have a field that will sometimes say "20 bundles" or "1 bundle" or "56 bundles".
I would like a formula I can use that will strip the word off the end and then add the bundle numbers together. The trouble I see is that it will sometimes be "bundles" and sometimes be "bundle".

I wonder if I were to do

CAST(RTRIM(LEFT(YourColumnName, LEN(YourColumnName) - 7)) AS integer)

would that do it, do you think?
 
Code:
CAST(LEFT(YourColumnName, CHARINDEX(' ',YourColumnName+' ')-1) AS int)

Not tested!

Borislav Borissov
VFP9 SP2, SQL Server
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top