Question:
Saving and displaying times with mysql?
Daniel B
2007-06-29 09:53:30 UTC
I am very new to php and mysql but have managed to make a database and display data. One problem i am having is with times in the format MM.SS.MS, this is the way i have imported the data in. is there a way to display it like this so it work properly. AT the moment if i order data it will put 10.23.34 before 8.35.24. These are times for a 800m swim. Minutes, seconds milli seconds. Thanks for your help. Dan
Four answers:
2007-06-29 10:12:35 UTC
You are better to store this kind of information converted to msecs. You can then get the php to re-calculate it on reading the data, and set up each item (MM,SS,MS) as a string and concatenate it to the others. During the string conversion you can use the string length to identify any item having a value under 10, then put a 0 on the front, thus 6 becomes 06, 4 becomes 04 etc. An empty item, as in zero seconds, can be set to 00, so you might end up with a time of 8.0.56 converting to 08.00.56. This will not only sort correctly, but will also display well in columns.
Seth E
2007-06-29 10:10:37 UTC
it is prob your data....if you loaded it 10.23.34 and 8.35.24...the first character it is comming by is 1 then 8.... put your data set into excel and format it as the MM.SS.MS so that it will come up 08....you do that and import again, and it should work...it will see the 0 before the 1 and keep sorting through





if you still have trouble... here is a good SQL site



http://www.techonthenet.com/index.php
TruthIsGod
2007-06-29 11:01:39 UTC
u can use a DATE_FORMAT function:

eg:

mysql> SELECT DATE_FORMAT('1997-10-04 22:23:00',

'%H %k %I %r %T %S %w');

-> '22 22 10 10:23:00 PM 22:23:00 00 6'



or



MAKETIME(hour,minute,second)







mysql> SELECT MAKETIME(12,15,30);

-> '12:15:30'
serravalli
2016-10-19 08:18:34 UTC
there's a provider referred to as FeedCatcher the place you place up a feed in accordance with a source record. That feeds then only keeps to append documents based on the updates to the source. i'm uncertain if this fits your applications, even in spite of the incontrovertible fact that it rather is rather useful to grant it a glance.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...