How to trim past certain character in BAQ

Hello,
Does anyone know how to trim a string past certain character, like “-” so when I have a part number say: 1006-500 it will look like 1006?

Thank you.

Most SQL commands with work in the BAQ custom field editor. looks like from the link that this would do it. (I haven’t tested it myself though)

LEFT(MyText, CHARINDEX(‘;’, MyText) - 1)

This works in an E9 calculated field.

substring(Part.PartNum,1,Index(Part.PartNum,"-"))
1 Like

Sorry, E-10 vs E9. I have to look at the category closer. Sorry.

Greg,
Thanks very much it works !! Now I have a part number with a “-” at the end. Is there any way to get rid of the “-” ?
I did that with Replace(Substring(InvcDtl.PartNum,1 ,Index(InvcDtl.PartNum,"-")),"-","")

Thanks you again

Sorry, this should do that.

substring(Part.PartNum,1,Index(Part.PartNum,"-") - 1)

1 Like

How well do the various sugesstions (Left(), SubString(), Index(), etc …) handle out of range values?

I’m thinking the cases where there is no “-”, or if it were the first character.

Use a case statement…
case when index = 0 then this else that end