0

I need insert in the table a date in this format:

11:40:18.111

My MySQL version is the 5.0.9, I've always used the Time Stamp, but I never needed use the milliseconds. How to write this data in the database in this format(HH:MM:SS.sss) and in this version of mysql?

Sorry for my bad english :P

  • maybe your answer is here. https://stackoverflow.com/questions/9624284/current-timestamp-in-milliseconds – Ibn Rushd Jul 17 '18 at 19:12
  • What is the struct of the table? – Geraldão de Rívia Jul 17 '18 at 19:15
  • 1
    MySQL 5.0.9 is positively baroque, it was released in 2005 and should be in a museum. You *need* to upgrade that. The upgrade path should be pretty seamless. Make backups, test the backups, and then bump to MySQL 5.7 if you can. You should see a huge speed boost as in the last 13 years there's been a number of dramatic improvements to the database engine. – tadman Jul 17 '18 at 19:26

1 Answers1

2

According to the MySQL 5.5 reference manual,

A DATETIME or TIMESTAMP value can include a trailing fractional seconds part in up to microseconds (6 digits) precision. Although this fractional part is recognized, it is discarded from values stored into DATETIME or TIMESTAMP columns.

MySQL 5.0 documentation (which should say the same thing) is available here.

It looks like support for fractional seconds was added in Version 5.7. So if you want native support for milliseconds, you'll need to upgrade.

If you're stuck with 5.0, you could have another field just for milliseconds. Of course, that'd get a bit tricky...

Zack
  • 2,220
  • 1
  • 8
  • 12