07-22-2019 01:33 AM
I had an interesting problem with some LabVIEW code which was being used to generate log files on a daily basis. One part of the code used the "Get Time/Date String" function to detect if the date had changed, then another VI was called that created a daily log file which contained in its filename the date read by the "Format Date/Time String" function.
For some reason the file being created always had the previous date, accidentally overwriting the previous days log file.
It appears that the two functions work slightly differently. I believe the "Get Time/Date String" function probably rounds up to the nearest second, whereas the "Format Date/Time String" function rounds down to the nearest second.
I altered the code to only use one of these functions and it solved the problem.
07-22-2019 02:13 AM
There could be many reasons (race conditions, etc.), that would explain the behavior.
Can you show some simple demo code that proves your suspicions?
07-22-2019 02:19 AM - edited 07-22-2019 02:22 AM
Here is some example code using the time section of the functions. The displayed times should be identical, but they are not.
07-22-2019 02:58 AM
Both functions have a timestamp input, so get that once and wire to both.
07-22-2019 03:21 AM
That's interesting. Wiring the same timestamp to both does indeed solve the problem. The routine for writing the file I am using is actually in a sub VI so I would have to wirethe timestamp all the way through.
Interestingly this also cures the problem:
Actually wiring the timestamp to the "Get Date/Time String" function rather than letting it default to the current timestamp.