Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Time rounding problem

Hi,

I'm trying to convert an input time that is provided as a decial number (e.g. 2.28, format is hours.minutes).

This shall be converted to 2:16, for 2 hours and 16 minutes This is my formula:

     =interval($(v_volume_fn)/24, 'hh:mm')&' Std.'

My problem is, that the calculated minute is not commercially rounded, but instead always rounded off (i.e. decimal values are cut off)

e.g. 2.28 is calculated to 2:16 (h:mm) (0,28*60 = 16.8 => 16)

but it should be

2.28 is calculated to 2:17 (h:mm) (0,28*60 = 16.8 = 17)

So the calculated minute is commercially rounded (i.e. [<0.5: round off]; [>=0.5: round up])

How can I achieve this?

Thanks

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

This will does it:

=Interval(MakeTime(Floor(2.28), Round(Frac(2.28)*60)))

Gives 2:17. Just insert your field in place of 2.28

HTH

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

View solution in original post

5 Replies
nirav_bhimani
Partner - Specialist
Partner - Specialist

Hi,

You can try this

=IF (Right (Num#(CalculatedValue,'# ##0.0'),1) <=5, Floor(CalculatedValue), Ceil(CalculatedValue))

For e.g.

=IF (Right (Num#(16.5,'# ##0.0'),1) <=5, Floor(16.5), Ceil(16.5))

Returns 16.

Is that you want.

Regards,

Nirav Bhimani

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

This will does it:

=Interval(MakeTime(Floor(2.28), Round(Frac(2.28)*60)))

Gives 2:17. Just insert your field in place of 2.28

HTH

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

Hi Jonathan,

this is exactly what I need. Many thanks!

Not applicable
Author

I found another issue.

The variable is used to record an amount of time, not limited by one day. With the maketime function, an amount of let's say 25 hours and 34 mins is set to NULL.

How can I handle this?

Not applicable
Author

Perhaps like this?

=interval(Floor($(v_volume_fn)) & ':' & Round(Frac($(v_volume_fn))*60), 'hh:mm')&' Std.'