LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Time Functions

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.

0 Kudos
Message 1 of 5
(2,208 Views)

There could be many reasons (race conditions, etc.), that would explain the behavior.

 

Can you show some simple demo code that proves your suspicions?

0 Kudos
Message 2 of 5
(2,178 Views)

Here is some example code using the time section of the functions. The displayed times should be identical, but they are not.

 

TimeDate Error.png

0 Kudos
Message 3 of 5
(2,169 Views)

Both functions have a timestamp input, so get that once and wire to both.

0 Kudos
Message 4 of 5
(2,131 Views)

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:

 

TimeDate Error 2.png

 

Actually wiring the timestamp to the "Get Date/Time String" function rather than letting it default to the current timestamp.

0 Kudos
Message 5 of 5
(2,121 Views)