Create a table with columns to store sub-second time

suggest change
CREATE TABLE times (
     dt DATETIME(3), 
     ts TIMESTAMP(3)
 );

makes a table with millisecond-precision date / time fields.

INSERT INTO times VALUES (NOW(3), NOW(3));

inserts a row containing NOW(3) values with millisecond precision. NOW() without an argument is only whole seconds, so the fractional part would be zero.

INSERT INTO times VALUES ('2015-01-01 16:34:00.123','2015-01-01 16:34:00.128');

inserts specific millisecond precision values.

Use NOW(3), not NOW(), when you insert through that function and want the extra precision. TIMESTAMP still converts to UTC for storage; DATETIME does not.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents