Solved

Inches to Feet & Inches?

Posted on 2004-09-03
4,580 Views
Need to convert inches to Feet & Inches, ie. 66" = 5' 6"

DB is MS SQL, Crystal Rep 9.0.

0
Question by:wcotis60
• 3
• 2

LVL 28

Expert Comment

ID: 11976806
Try this in a formula:

numbervar inches := 66;

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

LVL 28

Accepted Solution

bdreed35 earned 500 total points
ID: 11976855
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

LVL 26

Expert Comment

ID: 11976913
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

LVL 26

Expert Comment

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

LVL 26

Expert Comment

ID: 11977021
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

Expert Comment

ID: 11979571
:)
0

Featured Post

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…