Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

MYSQL time with fraction? GURU's challenge


emiliano

Recommended Posts

hello everybody.. i need some help from mysql gurus..

 

i'm trying to create a site to show rally car racing.. the problem is that i need to show fraction of second, and mysql doesn't support it yet.. (they said in the manual that they are going to support it.. only god knows when..)

 

someone have some solution to this..? another field isnt a solution..

 

cheers

emiliano

patagonia, argentina

Link to comment
Share on other sites

the problem is that i have 2 field.. in one table i have a field where i put the time when the car started to run.. then in another table i have another field where i put the time where it finished... eg start 14:00:00 pm finish 14:05:03.6

 

which means that the car took 5 min 3 seconds and 6 decimals of second..

 

your solution will require a intermediate pass to pass from the finished time to an int... or not?

 

thanks anyway

emiliano

patagonia, argentina

Link to comment
Share on other sites

Yes. Considering you don't have fractions of seconds in the database TIME field, you have to do it some other way.

 

So I propose milliseconds (one thousandth of a second) units. You'll have a good precision.

 

If you enter the time as hh:mm:ss:dd, you can convert the hh:mm:ss part with mktime(), multiply by 1000, and add the dd part times 100.

 

To get a time difference, substract start from finish (well, of course :oops:). To display, convert the other way: divide by 1000 and apply time(), etc.

Christian Lescuyer

Link to comment
Share on other sites

i'm back :)

 

i create a field called start_time int and another one called finish_time int

 

i only work with 1/10 sec.. so i insert 1269 if i want 2 minute 6 seconds and 9/10 sec..

 

i use time() to format my field, also i have to divide the field by 10, and use the floor() function to get rid of the decimals.. but the problem is, how to show the decimals only! i hope you do!

 

cheers

emiliano

patagonia, argentina

Link to comment
Share on other sites

hi.. i think that you didn't understand me.. but don't worry actually i have a really good thing to start.. now everything works..

 

it's time to code stilization (that's is a word?)..

patagonia, argentina

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...