|
||||
| ||||
|
|||||||
| OOTP Mods - Database Tools Do you need to take a dump? SQL gurus welcome |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Major Leagues
Join Date: Sep 2005
Location: Chicago, IL
Posts: 361
|
Converting Height?
anyone know how any tips on how to convert the height in the sql dumps from cm to feet and inches using mysql? thanks.
__________________
Phil Zuber Beyond the Ivy - Commish, Twins GM Stars and Stripes Baseball League - Cubs GM Bricks and Ivy - Orioles GM Sim Coalition - co-founder
|
|
|
|
|
|
#2 |
|
Major Leagues
Join Date: Sep 2005
Location: Chicago, IL
Posts: 361
|
anyone???
__________________
Phil Zuber Beyond the Ivy - Commish, Twins GM Stars and Stripes Baseball League - Cubs GM Bricks and Ivy - Orioles GM Sim Coalition - co-founder
|
|
|
|
|
|
#3 |
|
Major Leagues
Join Date: Mar 2003
Location: Newcastle, Australia
Posts: 302
|
Divide it by 2.54 to get it into inches.
Edit - sorry, didn't see the part about doing it in MySQL. Can't help you with that. Last edited by 21C; 08-29-2006 at 09:21 AM. |
|
|
|
|
|
#4 |
|
Bat Boy
Join Date: Jul 2003
Location: Los Angeles, CA but currently in Putney, VT
Posts: 6
|
Well I think this may work for getting the height into inches (this is based upon mysql hopefully it works in other sql). I don't know much about sql besides administering databases online but I found this in one of hte books I have.
The modulo operator; evaluates to the remainder of m divided by m % n is the same as MOD(m,n).. As with division, the modulo operator with a divisor of zero returns NULL. Here is a quote from Sam's MySQL "The modulo operator; evaluates to the remainder of m dived by m % n is the same as MOD(m,n). As with division, the modulo operator with a divisor of zero returns NULL." So therefore I think you can do the following Multiply cm x .39 then divid by 12 and strip anything to the right of the decimal point if one is returned. If you dont have any decimals then it is obviously a nice round number divisible by .39 which is very unlikely. When you do have something that is stripped then you have to take the original number you got after doing the first operation and then use the % to get the remainder which you add on to the original cmx.39 result stripped of the decimals. c=cm (cmx.39)/12=a a (rounded down, stripped of decimals whatever you want to call it or use to get a round number) is the number of feet. a%12=r R is the remainder and is the inches number. So therefore you can display as fllows A feet r inches and then make sure that you put somethign in there so that it does not show anythign for the inches if the remainder comes back as 0 and so that it says inch rather than inches if it is 1. Some modification will be needed as .39 is NOT an exact conversion factor so you may get a little error and you WILL need to round the inches using whatever method you choose so that you can get what you need, I'd say just round to the nearest whole number . I hope this helps but as I don't really understand too much of any type of sql and this is from a mysql book I'm not sure it will help but I hope you find it useful and it helps you figure out your conundrum. FIXED!
__________________
It's called baseball not foosball! Last edited by YoVivoPorSPORTS; 09-07-2006 at 01:08 AM. |
|
|
|
|
|
#5 |
|
Major Leagues
Join Date: Sep 2005
Location: Chicago, IL
Posts: 361
|
this doesnt work, dont use it
__________________
Phil Zuber Beyond the Ivy - Commish, Twins GM Stars and Stripes Baseball League - Cubs GM Bricks and Ivy - Orioles GM Sim Coalition - co-founder
|
|
|
|
|
|
#6 |
|
Major Leagues
Join Date: Sep 2005
Location: Chicago, IL
Posts: 361
|
i stand corrected, this formula will work.
the problem is that all the neccessary info wasnt here that i need to make it work, so i will reclarify it: $total_inches = 0.3937008*$AR_result[ 'height' ]; $feet = $total_inches/12; $inches=$total_inches%12; then to display, all you need is this: echo floor($feet)."' ".$inches."'';
__________________
Phil Zuber Beyond the Ivy - Commish, Twins GM Stars and Stripes Baseball League - Cubs GM Bricks and Ivy - Orioles GM Sim Coalition - co-founder
|
|
|
|
|
|
#7 |
|
Major Leagues
Join Date: Sep 2005
Location: Chicago, IL
Posts: 361
|
converting height
$total_inches = 0.3937008*$AR_result[ 'height' ];
$feet = $total_inches/12; $inches=$total_inches%12; then to display, all you need is this: echo floor($feet)."' ".$inches."''; i got it to work doing this. seems i forgot to strip the decimals and round down the first time, but i stumbled across it the other day, and sicne you had given up on it i had forgotten it. but thanks for the big step in the right direction.
__________________
Phil Zuber Beyond the Ivy - Commish, Twins GM Stars and Stripes Baseball League - Cubs GM Bricks and Ivy - Orioles GM Sim Coalition - co-founder
|
|
|
|
|
|
#8 |
|
Major Leagues
Join Date: Sep 2005
Location: Chicago, IL
Posts: 361
|
converting height
big thanks to YoVivoPorSPORTS for intially starting to help me with this. no way i would have gotten this far without it.
__________________
Phil Zuber Beyond the Ivy - Commish, Twins GM Stars and Stripes Baseball League - Cubs GM Bricks and Ivy - Orioles GM Sim Coalition - co-founder
|
|
|
|
![]() |
| Bookmarks |
|
|