# Inches to Feet & Inches?

Need to convert inches to Feet & Inches, ie. 66" = 5' 6"

DB is MS SQL, Crystal Rep 9.0.

###### Who is Participating?

Commented:
How is the field stored in the db?  As a number or as a string with the inches symbol?

If it is a number, my formula above will work fine.

If it is a string, you can change it this way:

numbervar inches := val('66"');

ToText(int(inches/12),0,"") & "' " & totext(remainder(inches,12),0) & '"'
0

Commented:
Try this in a formula:

numbervar inches := 66;

ToText(int(inches/12),0,"") & "' " & totext(remainder(inches,12),0) & "''"
0

Here's a formula that works for me:

NumberVar FeetConv;
NumberVar JustFeet;
NumberVar JustInches;
StringVar FeetText;

//Provides the base number of Feet and Inches in decimal format (5.5)
FeetConv := (72 / 12);

//Provides the base number of the Feet
JustFeet:= Truncate(FeetConv);

//Provides the base number of the Inches
JustInches := (FeetConv - JustFeet) * 12;

//Converts the Feet and Inches to Text for concatenation
FeetText := ToText(JustFeet,0) + "' " + ToText(JustInches,0) + '"';

//The resulting value...
FeetText;
0

Of course, you need to subsitute your actual field name for the number '72' in my example...
0

LOL, breed35 and I have posted at the same time on multiple threads now - i'm giving him grief in IM ;-).

His post is much less verbose, which is a good thing for experienced developers. I try to spell things out with variables to make it a little more clear what is going on.

I would accept breed35's answer ;-) (can't believe I'm saying that!)
0

Commented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.