# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Calculate time period in days, hours, minutes and seconds

I am trying to make a vi that calculates the time period in days, hours, minutes and seconds, but I can't find a smart and easy way to do it.. Since the days in a month varies, I have a problem to calculate the number of days in e.g. 4 months.

Does anyone have a clever solution to this problem?

Please have a look at the attached vi.

Regards

Paul

Message 1 of 3
(2,568 Views)
Solution
Accepted by topic author sandal

## Re: Calculate time period in days, hours, minutes and seconds

When you perform a math operation on two timestamps, the resulting output has a unit of seconds. You can use the Format into String function to convert those seconds into absoute time units.

AS you noted, months are relative and not supported in the format string function. A week is a constant of 7 days and can be calculated.

See attached...

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 2 of 3
(2,559 Views)

## Re: Calculate time period in days, hours, minutes and seconds

That was smart and easy. Thank you for your support!

Message 3 of 3
(2,549 Views)