digitai
digitai

Reputation: 1842

Mysql TIMEDIFF NULL values

I have a two TIME datatype columns table in mysql, ver 5.5.31 on DEBIAN. Need to get a time difference in seconds. Have used this query but just get NULL values. Any idea what is wrong with it? My query:

Select TIMESTAMPDIFF(SECOND, TIME(a.timestamp_end),     TIME(a.timestamp_start)) as total_time From  timestamp

However, what I get is NULL, instead of the expected INT that represents seconds between two times. Actually the data type for the columns is TIME, and this a sample of data stored: 07:11:40 07:11:56. In the case of this row, I should get 16 instead of NULL.

Upvotes: 2

Views: 2293

Answers (2)

Suleman khan
Suleman khan

Reputation: 1068

Try this out.

 SELECT TimestampDiff(SECOND, a.timestamp_end, a.timestamp_start) AS somename FROM table

Upvotes: 0

Sam
Sam

Reputation: 2761

Try

SELECT (SECOND(a.timestamp_end) - SECOND(a.timestamp_start)) as total_time 
FROM timestamp

Upvotes: 1

Related Questions