# Correct handling of milliseconds in a date time string

DateString[{2014, 5, 7, 13, 47, 44.760},
{"Year", "-", "Month", "-", "Day", " ", "Hour", ":", "Minute", ":", "Second", ".",
"Millisecond"}]


Returns 2014-05-07 13:47:44.759

The 44.760 can be 44.76 or 44.76 with no difference, replacing it with 44760/1000 does return 2014-05-07 13:47:44.760.

Presumably this is to do with 44.76 not being exactly represented as a machine precision number and milliseconds just cutting out the last 3 digits rather than rounding to 3 decimal places.

Can anyone suggest a simple fix?

Ugly but simple, and when you are only interested in milliseconds also correct for this use case.

DateString[{2014, 5, 7, 13, 47, Round[44.760,0.001] + 0.0001}, {"Year", "-",
"Month", "-", "Day", " ", "Hour", ":", "Minute", ":",
"SecondExact"}]
`