element for millisecond in time

Nagtegaal

Member
For a Sports website I am collcting and displaying achieved times on a race. In Sports it is quite common to store the millisecond. Just think about the world record of Usain Bolt for 100m. It is (as we all know:) 9.58s. In my case I only need one digit behind the second.

I am looking for the appropriate element to store this piece of data in. This is what I tried:
  1. The element - time plug-in has nice functionality, but does not support the milliseconds.
  2. I tried various formats with the date element, but I cannot find a way to enter the milliseconds.
  3. In MYSQL I created a table with TIME(1) field and 'imported' this into fabrik. In the list the times look fine, however there is no possibility to edit this field or add a new record with these times. Display is hh:MM:ss.S
upload_2019-10-29_15-4-20.png
trial 3: In form view editing is not possible.


Any help on this will be welcome.
 
Last edited:
After a night sleep I found a solution that works for microseconds. I thought I might as well post it, if ever someone ever runs into the same issue.

In the list I created the elements minutes, seconds and tenths (I only need 1 digit), which can be separately entered. From that I fill the time element 'tijd' with a trigger in the database. (A trigger I personally prefer over a calc field, just because I work a lot with SQL.) In the database table the type of the field is TIME(1).

The triggers I created in MYSQL:

CREATE TRIGGER `update_your_table_before` BEFORE UPDATE ON `your_table`
FOR EACH ROW BEGIN
SET NEW.tijd = cast(str_to_date(concat(NEW.minutes,":",NEW.seconds,".",NEW.tenths), '%i:%s.%f')as TIME(1));
END


CREATE TRIGGER `insert_your_table_before` BEFORE INSERT ON `your_table`
FOR EACH ROW BEGIN
SET NEW.tijd = cast(str_to_date(concat(NEW.minutes,":",NEW.seconds,".",NEW.tenths), '%i:%s.%f')as TIME(1));
END

In the list I hide the minutes, seconds and tenths elements and in the form view I hide the tijd element.

List View:

upload_2019-10-30_13-55-45.png

Form view:
upload_2019-10-30_13-57-38.png

In my case I do not need hours, but this can added in the same way (%H).
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top