Jump to content

Recommended Posts

Store it as a DECIMAL and calculate it like:

 

d = (h . 60 ^ 2) + (m . 60) + s + (n . 1 / 60)

 

function time2dec($hours, $minutes, $seconds, $hundreths) {
    return $hours * 3600 + $minutes * 60 + $seconds + $hundreths * 1 / 60; // 1/60 ~ 0.017
}

There is a problem with storing hundreths of a second within MYSQL.  Does anyone have a idea of how I can store 1 hours, 27 minutes, 15 seconds, and 85 hundreths of a second?

What about to store hundredths value in a separate INT column ?

 

Then he loses the flexibility of for example sorting

1:27:15,85

1:15:12,95

 

returns:

 

1:15:12,85

1:27:15,95

 

According to you that would be correct?

According to me that would be not. Please, pay attention that you broken rows and mixed one with another. It can not be.

 

Please, check:

 

CREATE TABLE `athletics_time` (
`main_time` TIME NOT NULL ,
`hundredths` INT NOT NULL 
);

INSERT INTO `athletics_time` (
`main_time` ,
`hundredths` 
)
VALUES (
'1:27:15', '85'
), (
'1:15:12', '95'
)
;

SELECT * 
FROM `athletics_time` 
ORDER BY main_time, hundredths
;

Please, pay attention that you broken rows and mixed one with another.

 

Oeps my bad I replied a bit to hasty. I had thought about it before I suggested the time2dec() using an extra column but forgot that MySQL does not sort by column but by row.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.