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

Pull seconds out of timestamp, use in functions

Hey,

Got a small issue here.  I have a data set with two timestamps, and in my script I'm pulling the interval between them and storing it in a column.  That interval is in 'ss' timestamp format, becuase I only want seconds:

Interval(AcceptTimestamp - CreateTimestamp, 'ss') as [Answer Time],

This gives me a column with only the second intervals, that I can them sum.

Only when I try to run AVG function like this:

=Avg([Answer Time])

to grab the average interval in whole seconds

Its grabbing the number number format (since qlikview stores date in two formats the string and the internal number)

and averaging off that , instead of the whole ss number I'm storing.  If your familiar with how qlikview stores timestamps you'll understand that, lol

does anyone know how to use avg function on units of time pulled off a datestamp?  Should I store the seconds as integers?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Num#(Interval(AcceptTimestamp - CreateTimestamp, 'ss'))  as [Answer Time in sec],

This will store your interval seconds as integers, not as fraction of days.

View solution in original post

5 Replies
Nicole-Smith

Have you tried wrapping the average in the interval() function?

=Interval(Avg([Answer Time]),'ss')

sunny_talwar

Interval works -> here is a sample attached

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Table:

Load *,

Interval(DateField1 - DateField2, 'ss')*24*60*60 as Seconds

FROM DataSource;

Now you can directly use Avg(Seconds) to get the average.

Hope this helps you.

Regadrs,

Jagan.

mohammadkhatimi
Partner - Specialist
Partner - Specialist

Hie..


Load *,

Interval(AcceptTimestamp - CreateTimestamp, 'ss')*24*60*60  as Sec

FROM table

---  24*60*60 is to convert days into secounds.

Afterwards use Avg(Sec)

Regards,

Mohammad.

swuehl
MVP
MVP

Num#(Interval(AcceptTimestamp - CreateTimestamp, 'ss'))  as [Answer Time in sec],

This will store your interval seconds as integers, not as fraction of days.