Which MySQL field(s) should I use to properly store date time with millisecond precision?
I know MySQL only has a second precision when storing datetimes and timestamps. So what is the best, simplest and most robust workaround you would recommend to include milliseconds?
So far I have seen DECIMAL(17,3) combined with SQL functions, and others serializing the datetime on a VARCHAR. Another idea would be to store the millisecond compo开发者_C百科nent in another column.
From the manual:
"...microseconds cannot be stored into a column of any temporal data type. Any microseconds part is discarded.
As of MySQL 5.0.8, conversion of TIME or DATETIME values to numeric form (for example, by adding +0) results in a double value with a microseconds part of .000000:"
So, it looks like using a doubel is the way to go.
精彩评论