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

Using the string function left(str,length)

Status
Not open for further replies.

rollypac

Programmer
Jun 13, 2003
23
US
When I use the string function left(str,length)it doesn't pull anything in. If I use the right(str,length) it pulls in what I want.
I have declared a string variable to use for the string.
Both the functions are pulling from the same field.

Any ideas why I'm not getting anything when I use the left function?
 
You probably don't need a string variable.

CrysUser makes a reasonable guess, you may have spaces in there. Please post exactly what you've tried, and the contents of the field.

You might also consider using the database to do this by leveraging a substring() function to gain performance, such as with sql server:

substring(table.field,<starting position>, <length>)

-k
 
Putting trim in the function doesn't work. It says too many parameters. Substring doesn't work either.
The function right(str,length) works fine with the same field with or without the variable declared.
 
Slight correction to CrysUser's post--there was a paren out of place:

Left(trim(string),length) //where length is the number of characters you want displayed

-LB
 
Substring does work, but it's dependent upon where you use it, the version of Crystal, and the version and type of the database.

I was simply trying to offload the real work to the database, but I think that this is too advanced to worry over right now, lbass has pointed out the flaw in CrysUser's formula, just use that.

-k
 
Moving the paran did the trick.
Thank you for all the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top