Average time in seconds

0

Hello, in my select I need to find the average service time (TMA) between two BIGINT format columns:

  

Date: DtBegin and DtEnd

asked by anonymous 24.05.2017 / 19:40

3 answers

0

It would be a conversion to DateTime with str_to_date , then # for an integer value and a division by 2 that would be the average of the result:

SELECT dtEnd, dtEnd, 
       ((UNIX_TIMESTAMP(dtEnd) - UNIX_TIMESTAMP(dtBegin)) / 2) media
from tempo tempo

The average in this case has its output in seconds like 30 seconds, 19 seconds, and so on.

References:

24.05.2017 / 19:59
0

Use the FROM_UNIXTIME function to convert to date and to make a difference to the TIMESTAMPDIFF function.

SELECT 
DtBegin,
DtEnd,
TIMESTAMPDIFF(SECOND,FROM_UNIXTIME(DtBegin),FROM_UNIXTIME(DtEnd)) AS TempoSegundos
from Interaction

SQLFIDDLE

    
24.05.2017 / 20:18
0

Friend! You are not able to use TIMESTAM because your data type is DATETIME . That is, your query is looking for one type of data being in the database is another.

    
20.07.2017 / 22:14