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!

Convert Feet and Inches to Inches

Status
Not open for further replies.

maengler2000

Technical User
Feb 2, 2012
7
US
My data is a string 5' 4" and I need to convert it to inches or 64"

We are using CR 2008.

Thanks for your help.
 
It would be a bit tricky since you would have to parse out each of the numbers then convert and do the math.

numbervar feet;
numberbar inches;
feet := val(left({field},instr({field},"'")-1);
inches := val(mid({field},{field},instr({field}," "), len({field}) -1);

feet *12 + inches

If I did the mid properly and the feet/inches are always formatted the same. I think this should work. Not tested.
 
another interesting option. This will also account for measurements without inches ex.. 6'

Code:
numbervar feet := val(split({@field},"'")[1]);
numbervar inches := if instr(split({@field},"'")[2],"""") > 0  then
    val(split(split({@field},"'")[2],"""")[1])
    else 0;
(feet*12) + inches;


_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Hi,

This is the problem working from a report, usually one generated by Unknown.

I'll bet that the source table has more definitive data: either in single units, defined with an additional UNITS field, or multi fields like FEET & INCHES. So my major quest would be to access the source data.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top