LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

second to hour min sec convertion

Hi! i have a sub vi named Sub_sec2hrmin.vi this vi we are using to calculate the run time and loss time. This vi is creating me a different kind of problem. We are taking seconds since jan 1 1904 and subtracting the current seconds from that input to get the time in hours and min.

If i am sending 60 seconds or 120 seconds it is showing normal.But if i send 6000 or 7000 seconds to it, it is showing -21 hours or some thing like that.

But same Vi is working properely in some computers. I am not able to dicide wheter the problem is from regional settings are from the logic. Please check the attached vi. Feed by feeding 6000 sec. input.

Regards
Ramme
0 Kudos
Message 1 of 4
(3,500 Views)
The problem why you get the negative value is logical. You wire a value to the Seconds To Date/Time function. This results in two different date/time clusters.
Let's say cluster one contains as a time 14:12:55 and the second contains 12:25:33.
 
You subtract the second from the first one so you have 14 - 12 = 2, 12 - 25 = -13 and 55 - 33 = 22. It rather would be 27 seconds to fill the minute of cluster two, 34 minutes to fill the hour, 1 hour to math cluster one plus 12 minutes and 55 seconds. This results in 1hour, 46minutes and 82 seconds. These values should be recalculated to 1hour, 47minutes and 22seconds. As you can see, it is not that simple to calculate the time. You can not just subtract the two values.
 
If I have to calculate times, I usually have a vi like the one attached.
 
I hope this helps you.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 2 of 4
(3,495 Views)
Sorry, but your VI makes very little sense to me.
 
Are you are taking two reading in seconds since Jan 1, 2004, then take the difference to calculate the elapsed time?  However you "SecInput" has a default value of only 7200, so your time difference is ~3.09102E+9 seconds. Then you are subtracting the seconds, minutes and hours, individually without worrying about any carry that might occur. I would say the logic is completely off.
 
Alternatively, if you are just using the SecInput for the elapsed time, none of the operations and subtrations make sense. You could just do something liike in the image to extract seconds, minutes, and hours from a "seconds" input. Why would you need the 1904 time at all?
 
 
 

Message Edited by altenbach on 08-16-2006 10:57 PM

0 Kudos
Message 3 of 4
(3,493 Views)
Thanks for the replies, i tried the direct seconds conversion, but it requires more data logs to create in my program. If i am calculating the time with reference to the seconds since 1 jan 1904 it can show the time directly. But now i dicided to change the old logic and decvelop new for the same.

Thankyou verymuch for the replies...

Regards
Ramesh.C
0 Kudos
Message 4 of 4
(3,455 Views)