Skip to main content
Solved

Seconds to h/m/s but more than 24h


becchr
Influencer
Forum|alt.badge.img+23

Hi, this must be easy but can't seem to find it...

I want to convert duration from seconds to hours, minutes, seconds. So 337759 seconds should be 93h49m19s.

I thought the DateTimeConverter should help me, but can't seem to get it right:

results in 21h49m19s...

I could calculate it myself, but I guess I'm overlooking a setting in this transformer?

Best answer by jlbaker2779

Don't think you can use the dates like that. Everything is 24 hour. If the seconds go over 31 days, you'll need to change the 1st DateTimeConverter to %j to account for months.

 

Here's a simple workaround that should work.

 

 

Attached .fmwt

View original
Did this help you find an answer to your question?

4 replies

Forum|alt.badge.img+2
  • Best Answer
  • June 6, 2020

Don't think you can use the dates like that. Everything is 24 hour. If the seconds go over 31 days, you'll need to change the 1st DateTimeConverter to %j to account for months.

 

Here's a simple workaround that should work.

 

 

Attached .fmwt


takashi
Contributor
Forum|alt.badge.img+17
  • Contributor
  • June 7, 2020

I think these three math operations and one string concatenation could always generate required value, even if the duration was greater than 31 days (=2,678,400 seconds). Assuming that an attribute called "duration" stores the original duration value in seconds, like 337759, 3000000 etc.

h = @int(@Value(duration)/3600)
m = @int((@Value(duration)-@Value(h)*3600)/60)
s = @Value(duration)%60
hms = @Value(h):@Value(m):@Value(s)

Setting example with an AttributeCreator

0684Q00000ArLLNQA3.png


becchr
Influencer
Forum|alt.badge.img+23
  • Author
  • Influencer
  • June 7, 2020
takashi wrote:

I think these three math operations and one string concatenation could always generate required value, even if the duration was greater than 31 days (=2,678,400 seconds). Assuming that an attribute called "duration" stores the original duration value in seconds, like 337759, 3000000 etc.

h = @int(@Value(duration)/3600)
m = @int((@Value(duration)-@Value(h)*3600)/60)
s = @Value(duration)%60
hms = @Value(h):@Value(m):@Value(s)

Setting example with an AttributeCreator

0684Q00000ArLLNQA3.png

thank you @jlbaker2779 and @takashi for your suggestions, I agree it's easy to calculate yourself but still feels a bit cumbersome, especially if you want to do it for several attributes at once...

So I think it's worth a new idea to make this possible in the DateTimeConverter

https://knowledge.safe.com/idea/115166/datetimeconverter-add-up-more-than-24hours.html? 

I had this similar but needlessly more complicated workaround :

0684Q00000ArMdeQAF.png


philippeb
Enthusiast
Forum|alt.badge.img+16
  • Enthusiast
  • October 2, 2024

Yeah that should be easier to calculate! I agree with you!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings