Insert date, hour, minutes, seconds and milliseconds in MYSQL

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

Upvotes: 0

Views: 2053

Answers (1)

Zack
Zack

Reputation: 2341

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...

Upvotes: 2

Related Questions