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!

How to do a Mid?

Status
Not open for further replies.
Dec 27, 2002
167
US
I have a report that I am using from one database to another.
No problem seting the new location.

When I run it it turns out one of the feilds is backwards and my formula no longer works.

Here is what the formula does.

ToNumber (Left ({LABOR_TICKET.EMPLOYEE_ID},2))

The old Data looked like this.
03MANCREW
The new data looks like this.
CREW03-1

I need to change the formula to capture the 4th and 3rd Character from the Right. It will alwasy be the 4th and 3rd Characet from the Right. THe First Character varies too much from the left position.

Basically I want to do a left 2 of a Right 4

I've tried this
stringVar RIGHT_SIDE:= RIGHT ({LABOR_TICKET.EMPLOYEE_ID}, 4);

ToNumber (Left (RIGHT_SIDE,2))

But it didn't work.
 
ToNumber(Mid({LABOR_TICKET.EMPLOYEE_ID}, 5, 2))

That would work with the sample above
CREW03-1

But the 03 is not always the 5th and 6th position.
 
Whoops, my mistake.

THe First Character varies too much from the left position.

didn't see that there.

Anyway, you could try adding a WhilePrintingRecords to your formula with the variable which would look like the following:

WhilePrintingRecords;
stringVar RIGHT_SIDE:= RIGHT ({LABOR_TICKET.EMPLOYEE_ID}, 4);

ToNumber (Left (RIGHT_SIDE,2));

However I try to avoid using variables when they aren't necessary. In this case you could take the Left function of the Right function directly.

Left(Right({LABOR_TICKET.EMPLOYEE_ID}, 2), 4)

I hope I was alittle more helpful this time around.
 
I'll try it, but it looks like you have it in reverse

I think it should be
Left(Right({LABOR_TICKET.EMPLOYEE_ID}, 4), 2)

I wanted the 2 left most characters of the 4 right most.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top