I have a date in standard SQL format YYYY-MM-DD HH:MM:SS.xx, where the xx are hundredths of seconds:
x = 2016-05-30 11:58:46.84
I have a file with 200,000+ records like this. I need to compare this file to a similar file with (mostly) the same information where, however, the seconds are expressed with 6 decimals. So I need to pad zeros on the right of the seconds in the above. Here is what what I did. (NB: I am using the indentation formatting liberally to help readability, even when I am not actually entering MMA code.)
I transformed x to DateList format:
y = DateList[x] = {2016, 5, 30, 11, 58, 46.84}
Then I picked the 6th entry of the list and padded the zeros on:
z = NumberForm[y[[6]], {5, 6}] = 46.840000
Now I have to rebuild the original SQL datetime number carrying along the newly padded zeros:
y[[6]] = z;
Such that now
y = {2016, 5, 30, 11, 58, 46.840000}
I am stuck on the very last step. How do I go from the latest format of y above back to
2016-05-30 11:58:46.840000 ??
I looked for type or format conversion functions but no joy so far. Apologies if this is a stupid question with an obvious answer!
DateString
documentation, unless I missed the point you can specify it directly. $\endgroup$