LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

timestamp rounding problem

Solved!
Go to solution

In a state machine I'm setting the current time for a process as the start time and adding 6 hours for end time in the initial state. Later in the 7th state, i can change the start time and the second/ms value rounds off (e.g. 12:30:00.000 PM) but the end time when changed rounds off to say 4:20:39.333 PM. But I want it to look like 4:20:00.000 PM. What do I do? [Increment value for both are 60, coerce down]

0 Kudos
Message 1 of 17
(1,185 Views)

Attach your vi or a code snippet so we can see what you're doing, then maybe someone can comment on how to fix it.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 2 of 17
(1,181 Views)

tabs-FS is the main VI and 6hours is the subVI used. Look into Initialize and Scheme states of tabs-FS. Other subVIs are too large to attach. Thanks.

0 Kudos
Message 3 of 17
(1,179 Views)

 

For the indicator, truncate the wire value to a multiple of 60 using code, e.g. as follows:

 

 

 

Alternatively, you can change the display format to omit the seconds. (see image)

 

 

No need to show the seconds....


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 4 of 17
(1,170 Views)
Solution
Accepted by topic author shreya005
08-27-2015 04:09 PM

Also note that the subVI code could be simplified dramatically.

 

You don't need to unbundle-rebundle all elements, just the one that changes (hours, top image)

Even simpler, add the number of seconds to the timestamp (bottom image).

 

 


LabVIEW Champion Do more with less code and in less time
Message 5 of 17
(1,169 Views)

@ thanks for the simplification for addition of 6 hours. but the rounding off problem still exists. even though the display format is as required, the exact values in the probe watch window show the 39.333s in the end time. As this is to be implemented for a practical application later, it has to be exactly 6hours, cannot have the 39.333 seconds

0 Kudos
Message 6 of 17
(1,157 Views)

@shreya005 wrote:

As this is to be implemented for a practical application later, it has to be exactly 6hours, cannot have the 39.333 seconds


Did you try the two methods I showed above (truncate the timestamp in the wire going to the indicator or change the display format). If you don't show seconds, they cannot be wrong Smiley Wink


LabVIEW Champion Do more with less code and in less time
0 Kudos
Message 7 of 17
(1,137 Views)

i implemented the truncate function it works. thanks Smiley Happy

0 Kudos
Message 8 of 17
(1,126 Views)

@altenbach wrote:

Also note that the subVI code could be simplified dramatically.

 

You don't need to unbundle-rebundle all elements, just the one that changes (hours, top image)

Even simpler, add the number of seconds to the timestamp (bottom image).

 

 


Jim Kring posted a few years ago on his blog a cool feature of timestamps; they support units!

 

You can set the units for the constant to hours and add that directly to the timestamp; no units scaling required...

 

(Oops; looks like altenbach commented on that blog, you already know about this)

 

http://thinkinging.com/2007/06/08/labview-tip-easy-relative-timestamp-calculations/

 

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

Message 9 of 17
(1,111 Views)

@PhillipBrooks wrote:

@altenbach wrote:

Also note that the subVI code could be simplified dramatically.

 

You don't need to unbundle-rebundle all elements, just the one that changes (hours, top image)

Even simpler, add the number of seconds to the timestamp (bottom image).

 

 


Jim Kring posted a few years ago on his blog a cool feature of timestamps; they support units!

 

You can set the units for the constant to hours and add that directly to the timestamp; no units scaling required...

 

(Oops; looks like altenbach commented on that blog, you already know about this)

 

http://thinkinging.com/2007/06/08/labview-tip-easy-relative-timestamp-calculations/

 

 


Doesn't mean that old... umm... hands... don't need reminding every so often.  Smiley Wink

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 10 of 17
(1,083 Views)