Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
MarcoARaymundo
Creator III
Creator III

Decimal hours to D hh:mm

Hi!

I have two fields DT END and DT START in format "DD/MM/YYYY hh:mm:ss".

I need to calculate the difference between them and show the format "D hh: mm".

The problem is that I calculate for every 8 working hours.

Anyone can help me?

tks

1 Solution

Accepted Solutions
MarcoARaymundo
Creator III
Creator III
Author

Hi!

Thank you all for responding me.

Below I leave my version to solve the problem, I hope it helps others.

Interval(If((DT_END - DT_START) >= Num(TimeStamp(TimeStamp#('8', 'hh'))),

  If(Frac(((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh'))))) > Num(TimeStamp(TimeStamp#('8', 'hh'))),

  (((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh')))) - Frac(((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh')))))) +

  (

  (DT_END - DT_START) -

  (((((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh')))) - Frac(((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh'))))))) * Num(TimeStamp(TimeStamp#('8', 'hh'))))

  ),

  ((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh'))))

  ),

  (DT_END - DT_START)

), 'D hh:mm')

View solution in original post

4 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

=Interval( [DT END]- [DT START]), 'DD:hh:mm:ss')

If it is not what you expected can you come up with example what exactly you need.

Regards,

Jagan.

qlikpahadi07
Specialist
Specialist

can you attach a sample 

crusader_
Partner - Specialist
Partner - Specialist

Hi Marco,

As I understood You need to increment next day after every 8 hours, if it is, just try this thing:

=Timestamp#(interval(interval([timestamp(DT END)]-[timestamp(start)],'hh')/8,'hh')&' '

  &(num#(text(interval([timestamp(DT END)]-[timestamp(DT START)],'hh')),'#')-num#(text(interval(interval([timestamp(DT END)]-[timestamp(DT START)],'hh')/8,'hh')),'#')*8)&':'&

  (num#(text(interval([timestamp(DT END)]-[timestamp(DT START)],'mm')),'#')-num#(text(interval(interval([timestamp(DT END)]-[timestamp(DT START)],'mm')/60,'mm')),'#')*60),'DD hh:mm')

It doesn't look gracefully, but it works.

MarcoARaymundo
Creator III
Creator III
Author

Hi!

Thank you all for responding me.

Below I leave my version to solve the problem, I hope it helps others.

Interval(If((DT_END - DT_START) >= Num(TimeStamp(TimeStamp#('8', 'hh'))),

  If(Frac(((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh'))))) > Num(TimeStamp(TimeStamp#('8', 'hh'))),

  (((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh')))) - Frac(((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh')))))) +

  (

  (DT_END - DT_START) -

  (((((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh')))) - Frac(((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh'))))))) * Num(TimeStamp(TimeStamp#('8', 'hh'))))

  ),

  ((DT_END - DT_START) / Num(TimeStamp(TimeStamp#('8', 'hh'))))

  ),

  (DT_END - DT_START)

), 'D hh:mm')