I have this issue where dates are seemingly being ...
# cfml-general
r
I have this issue where dates are seemingly being rounded when saved to a mysql database. This is causing some tests to fail when creating a pull request for quick. I am not 100% sure how to go about addressing this so looking for some comments.
image.png
Here is the code + output
If you check createdDate or modifiedDate you will see they differ by one second
d
Is that behavior consistent? Maybe set a var to now(), then use the var when you create the record? I've never seen now() differ by that much in a single block of code though.
r
I did try that but its the same result. The issue seems to stem from when the date is saved to the database as it looks like the quick library (maybe qb) sets the query parameter to include the millisecond part. Mysql seem to round this to the nearest second which will cause some tests to fail because the dates dont match.
image.png
Ah ok it seems that the timestamp datatype in mysql does not store millisecond by default you have to specify a precision.
☝🏻 1
e
the other option would be to store your timestamp field in one column then add the exact time in a second column as a number or string. You end up with a tiny bit of overhead, but it doesn't matter, even on millions of records.