Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Convert a duration into a number of hours

Hello everyone,

I have a metric which provides me a duration in the following format : HH:SS

I would like to obtain a numeric value indicating the exact number of hours for this duration.
for example if the duration is 03:30 (3h30min) I want to obtain 3.5 as a number.

Is there any function that could help me with that ?

Thanks you very much

Alexandre BERNARD

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Multiply by 24 rather than divde:

     Interval#('3:30', 'H:mm') * 24 = 3.5

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

6 Replies
m_woolf
Master II
Master II

If the duration is a timestamp, you can divide by 24.

Anonymous
Not applicable
Author

try this and use your timefield instead of "03:30"

=num(left('03:30',2) & ',' & Right('03:30',2)/6)

Not applicable
Author

The problem is that I want to convert a duration into a number. The format is different so I cant Divide it.
Are there any functions that convert Time duration into numbers ?

jonathandienst
Partner - Champion III
Partner - Champion III

Multiply by 24 rather than divde:

     Interval#('3:30', 'H:mm') * 24 = 3.5

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

If the time duration is calculated using QV time values and functions, it is actually a number, representing days. Shorter intervals will be fractions of a day; 1 hour has a value of 1/24. So if you multiply the interval by 24 you will get a value in decimal hours.

If the interval is a string value, then you can convert that to a QV numeric interval using Interval# (as I did above).

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

Hi Alexandre,

Please try:

Convert time stamp into hour decimal value :

hour( interval(([timestamp]/86400), 'hh:mm:ss') )

           + (((Minute (interval(([timestamp]/86400), 'hh:mm:ss')) * 100) / 60)

           + (Second (interval(([timestamp]/86400), 'hh:mm:ss')) * 100) / 3600 ) / 100

or

If the field is TimeSecond then you can convert using below:

(TimeSecond /3600)  which converts Seconds to duration in decimal

Regards

Neetha