Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

subtract times with AM and PM values

Hi all.

I have a csv file with two different columns:

START                         END

8:00 AM                       9:00 AM

10:15 AM                      12:00 M

I need to calculate the time difference in hours and minutes.

I tried:

interval(END]-[START], 'hh:mm')

And nothing happens. I think that the time fields are not well format, so I tried again:

Interval(Time#([END],'hh:mm') - Time#([START],'hh:mm'),'hh:mm')

And again, doesn't work.

Suggestions?

1 Solution

Accepted Solutions
maxgro
MVP
MVP

you just miss the tt

have a look at format code in QlikView help

Times

  • To describe the hours, use the symbol "h" for each digit. 
  • To describe the minutes, use the symbol "m" for each digit. 
  • To describe the seconds, use the symbol "s" for each digit. 
  • To describe the fractions of a second, use the symbol "f" for each digit. 
  • To describe the time in AM/PM format, use the symbol "tt" after the time. 
  • Arbitrary separators can be used.

Examples (Time):

hh:mm describes the time as 18:30

hh.mm.ss.ff describes the time as 18.30.00.00

hh:mm:tt describes the time as 06:30:pm

View solution in original post

7 Replies
sunny_talwar

Try this:

Interval(Time#([END],'hh:mm TT') - Time#([START],'hh:mm TT'),'hh:mm')

javier_florian
Creator III
Creator III

Hi Chang,

You would use the follow formula:

=Time(Your_Field,'TT')

maxgro
MVP
MVP

you just miss the tt

have a look at format code in QlikView help

Times

  • To describe the hours, use the symbol "h" for each digit. 
  • To describe the minutes, use the symbol "m" for each digit. 
  • To describe the seconds, use the symbol "s" for each digit. 
  • To describe the fractions of a second, use the symbol "f" for each digit. 
  • To describe the time in AM/PM format, use the symbol "tt" after the time. 
  • Arbitrary separators can be used.

Examples (Time):

hh:mm describes the time as 18:30

hh.mm.ss.ff describes the time as 18.30.00.00

hh:mm:tt describes the time as 06:30:pm

Not applicable
Author

Thanks it worked!

sunny_talwar

Hahahaha mine worked but the correct answer is going to maxgro .

JK. I am glad we were able to help.

Best,

Sunny

Not applicable
Author

Sorry with the documentation reference of maxgro i also solved other questions.

You rocks Sunny!

sunny_talwar