Why are fractional seconds in date/time values truncated in MySql/MariaDB?

0 votes
asked May 21, 2020 by rich-c-2789 (17,490 points)
edited May 21, 2020 by rich-c-2789
I have a QIE database connection to a MySql/MariaDB database and I need to store date/time values and preserve the fractional seconds. When I send something like this "2020-05-21 01:41:30.059" the fractional seconds (.059) appear to be truncated.

Is there a way to preserve the fractional seconds?

1 Answer

0 votes

Fractional second support in MySql and MariaDB is dependent on the fields definition.  If you have control over the DDL to create the tables then check to make sure the field is defined so that it supports fractional seconds.  You will first need to adjust your CREATE TABLE statements to provide the precision needed.

For example:  

       "myDateField DATETIME" 


        "myDateField DATETIME(0)" 

    do not support fractional seconds.


        "myDateField DATETIME(6)

    does supports fractional seconds up to micro seconds.



You may also need to make sure you send fractional seconds by checking your connection URL/Strings for the appropriate use of this connection property/parameter: sendFractionalSeconds (Mysql)/useFractionalSeconds (MariaDB)


answered May 21, 2020 by rich-c-2789 (17,490 points)