Totes Posted January 1, 2007 Posted January 1, 2007 Hi, I have a field for a person height, and I have attempted to convert a persons height from: 610 to 6'10" or 63 to 6'3" I can get the first sign for the feet (') but I cant get the inch sign (") to set properly it keeps adding the first number to the end. Can someone help, I have done a search but cannot find anything. Thanks
Lee Smith Posted January 1, 2007 Posted January 1, 2007 Heres a calculation that BobWeaver posted a couple of years ago that should do what you want. Int([color:blue]Inches / 12) & "'" & " " & Mod( [color:blue]Inches;12) & """ If your Field name is not Inches, substitute it for Inches in this calculation. HTH Lee
Totes Posted January 1, 2007 Author Posted January 1, 2007 (edited) Lee, Thanks, I put it in place and it is placing the (') and the (") in the correct location however it is converting total inches... to feet & inches. The user of this DB will know that the person is 6 feet, 3 inches, so they would enter 63, and I need a calc that would change it to 6'3". What I tried to do was a similar to my phone calc that I have: Let( P = Filter(Phones; "1234567890" ); "(" & Left( P; 3 ) & ") " & Middle( P; 4; 3 ) & "-" & Middle( P; 7; 4 ) ) I was attempting to use a variant of the above phone calc(of course cut down to filter 3 numbers). but I could not get it to work, if the person was 6'10" it would return 6'1" (I would post a copy of what I had, however I gave up and deleted it) Edited January 1, 2007 by Guest
comment Posted January 1, 2007 Posted January 1, 2007 Try: Left ( Height ; 1 ) & "' " & Right ( Height ; Length ( Height ) - 1 ) & """ If it were me, I'd put feet and inches in two separate fields.
Totes Posted January 1, 2007 Author Posted January 1, 2007 Thanks comment that one worked. See, I never even thought of breaking down the feet and inches into 2 fields, that would have saved me many many hours of beating my head on the desk. May I ask one: I was not toooooo far off from the solution you posted, however I did not have the "Lenght -1" in my original calc. Could you explain that to me or point me to something that would better explain this calc to me. I really do not fully understand this one. Thanks, James
comment Posted January 1, 2007 Posted January 1, 2007 The basic assumption here is that no one is shorter that 1' or taller than 9'11". So the first character in the string is always the feet component. The rest of the characters form the inch component. The string's overall length can be either 2 or 3 characters. To extract all characters except the first (i.e. leftmost) one, you'd take the characters starting from the right, and ending just before the last one.
The Shadow Posted January 1, 2007 Posted January 1, 2007 A slight modification will allow comment's calc to work even if users enter the correct format (6'10") also: Let ( myHeight = Filter( Height; "0123456789" ); Left ( myHeight ; 1 ) & "' " & Right ( myHeight ; Length ( myHeight ) - 1 ) & """ )
Recommended Posts
This topic is 6537 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now