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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Replace Funtion trying to replace everything behind "-" 1

Status
Not open for further replies.

trialbyfire

IS-IT--Management
May 11, 2002
19
US
I am trying to take a string similar to 524-0982 or 62341-90823 and displaying just the digits before the dash. However the wild card operators do not appear to be working for me. Formula is as follows,

Replace ({custname.cust-code},"-*","")

If I remove the " from the "-*" the formula does not recognize the - as a string. However the formula above does not appear to be working. Can someone out there give me some help.
 
Try:

if instr({table.field},"-") > 0 then
left({table,field},instr({table.field},"-")-1)
else
{table,field}

This will return the first digits if there exists a dash, otherwise the whole field.

-k
 
Instead of using replace, how about something like this:

Left({custname.cust-code}, (InStr({custname.cust-code},'-') - 1))

InStr will return the position of the '-' character.
Left will get you all of the characters to the left of '-'.

-D
 
Worked like a charm synapsevampire. Thank-you for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top