?
Solved

Milliseconds time format in My SQL

Posted on 2003-03-26
4
Medium Priority
?
1,854 Views
Last Modified: 2008-02-01
Can any one help.
How do you configure a table field for milliseconds in MySQL?

eg. HH:MM:SS:AAA

AAA=milliseconds

I want to create a database that holds lap records for games.

Please help me.

PBUK.
0
Comment
Question by:PBUK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:VGR
ID: 8210832
you CAN'T

use a varchar field, they are asisgnation-compatible with TIMESTAMPS and DATE/TIME

http://www.mysql.com/doc/en/Date_and_time_functions.html
0
 
LVL 15

Accepted Solution

by:
VGR earned 200 total points
ID: 8210839
in the case this is useful to you, this computes delta times in milliseconds :

<?
//VGR14042001 Creation
//VGR24112002 ADDed sécurité pour mode globDisc
//

//
// ----------------------------- FORUM -----------------------------------
//
function myTime() { // en secondes
$loc1=microtime();
$loc2 = (double)substr (strrchr ($loc1, ' '), 1); // secondes entières
$loc3 = (double)substr ($loc1, 1,strpos($loc1,' ')); // fraction de seconde = 0.xxx
$loc2 = $loc2+$loc3;
//test
//echo "time $loc1 -> $loc2<BR>";
//
return $loc2;
}

function TimerStart() {
  GLOBAL $TTime;
  $TTime=myTime();
} // TimerStart Procedure

function TimerStop($parDisp=FALSE) { // and display
  GLOBAL $TTime;
  $locTime=myTime()-$TTime; // en secondes
  //VGR14042001 BUGFIX
  // il y a un bug dans la fonction de base : la seconde n'est pas incrémentée correctement.
  if ($locTime<0) $locTime=1.0+$locTime;
  //EoFIX
  $locTime=round(1000.0*$locTime,5); // millisecondes arrondies à la 5ème décimale
  if ($parDisp) echo "<BR><CENTER><font size=-2>page generated in $locTime milliseconds</font></CENTER>";
  return($locTime);
} // TimerStop Integer (ms) Function
?>
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question