13 Replies Latest reply: Sep 28, 2016 10:48 AM by Lakshmikandh Karthikeyan

# Time interval

Hi Everyone ,

I have requirements I need get  interval between current date and previous date by hour

for example 1/30/2016 10:30:23 am

1/30/2016 12:30:30 pm

my output is  2 hours

• ###### Re: Time interval

Try this:

Interval(CurrentDate - PreviousDate, 'hh')

• ###### Re: Time interval

For you example:

=Interval(Timestamp#('1/30/2016 12:30:30 PM', 'M/D/YYYY h:mm:ss TT') - Timestamp#('1/30/2016 10:30:23 AM', 'M/D/YYYY h:mm:ss TT'), 'h')

• ###### Re: Time interval

Both are same  Field

Example

1/30/2016 10:30:23 am -   0 hh(ouput)

1/30/2016 12:30:30 pm-    2 hh(output)

1/30/2016 15:30:30 pm -     3  hh(output)

Like wise

• ###### Re: Time interval

Where are you trying to do this? Script or chart?

• ###### Re: Time interval

Script

• ###### Re: Time interval

You can use Peek() or Previous()

Interval(DateTime - Previous(DateTime), 'hh')

• ###### Re: Time interval

Not working in  my Case

• ###### Re: Time interval

Would you be able to provide few rows of data of how your data looks like?

• ###### Re: Time interval

These are all within the same hour? What output do you expect to see?

• ###### Re: Time interval

Also are there any other dimension where this needs to reset?

• ###### Re: Time interval

No,not same hour

I wanted to show current date  and previous date by hour difference

My Output : 2 (hh)

• ###### Re: Time interval

Hi,

Please have a look at these time functions as well.

https://help.qlik.com/en-US/sense/3.1/Subsystems/Hub/Content/Scripting/DateAndTimeFunctions/date-time-functions.htm

This will be helpful in future works.

Thanks,

Lakshmikandh