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: 
marjan_it
Creator III
Creator III

how to get sum of 2 time field

how to get sum of 2 time field that have more than 24 hours

I want to get sum 2 time in expression in qlikview like this: 20:25:50 and 22:45:15

And in result show this:43:11:05

9 Replies
tresesco
MVP
MVP

If the fields are proper timestamps, simple addition like:

Load

          Timestamp(Field1+Field2) as NewField

should work;

marjan_it
Creator III
Creator III
Author

No, its not timestamp. its just a time in this format: hh:mm:ss like 20:25:50

tresesco
MVP
MVP

Try like:

Load

Timestamp(Timestamp#(Field1, 'hh:mm:ss')+Timestamp#(Field2, 'hh:mm:ss')) as NewField

MK_QSL
MVP
MVP

Try

=Interval(Time('20:25:50') + Time('22:45:15'))

or

=Interval(Time(Field1) + Time(Field2))

or

Interval(Time(Field1) + Time(Field2)) as NewField

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Try like:

Load

*,

Interval(Timestamp#(Field1, 'hh:mm:ss')+Timestamp#(Field2, 'hh:mm:ss'), 'hh:mm:ss')

FROM DataSource;

Hope this helps you.

Regards,

Jagan.

Greg_Williams
Former Employee
Former Employee

I had a similar issue...my formula looked something like this...used it in a text box, then switched it over to a list box Expression beside the User.

=time(  sum(  DISTINCT [Session Duration]),'hh:mm:ss')

Also - have you tried sub(Time_Field) and grab each component of the time. Multiply time the appropriate value minutes > to seconds = result * 60 (e.g.) then add the components together?

My quantity of times varied and the above formula worked for me if I had one time or 20 times.

Another thought - have you considered aggr'ing based on specific field (that makes sense for you (e.g. year, month, etc.)?

Hope this helps.

MarcoWedel

if it's real time/interval values (numerical 0-1) then

Interval(Timefield1+Timefield2)

should do. Otherwise if it's two timestamps you have to first extract the fractional part from the timefields like

Interval(Frac(Timestampfield1)+Frac(Timestampfield2))

hope this helps

regards

Marco

b_garside
Partner - Specialist
Partner - Specialist

jagangmohan‌,

Just tried this it works in a Text box, but not in the script. Any ideas why?

see below.

Interval(Timestamp#(F16,'hh:mm:ss')+Timestamp#(F17, 'hh:mm:ss'), 'hh:mm:ss') as $(vUIAvgACDTime),

Capture.PNG

b_garside
Partner - Specialist
Partner - Specialist

jagangmohan‌  Nevermind. I just had to simplify it to:

Interval(F16 + F17, 'hh:mm:ss')