Thursday, 15 March 2012

mysql - SEC_TO_TIME time error -



mysql - SEC_TO_TIME time error -

i testing out queries create sure giving proper results. noticed getting wrong time. 1 of timestamps

2013-02-07 07:26:04

and subtract :

2013-02-07 07:18:23

from first time stamp

and giving me difference of twelve or minutes. i'm not math genius can 18 - 12 = 6... not 12... knew there problem query. removed sec_to_time , gave me right time diff of :

+------------+-----------+--------------+----------------+--------+----------+ | session_id | anum | first | lastly | why | time | +------------+-----------+--------------+----------------+--------+----------+ | 220 | b00000000 | testing | thisout | other | 00:07:41 | +------------+-----------+--------------+----------------+--------+----------+ query : select session.session_id, session.anum, student.first, student.last, session.why, (timediff(t.fin, session.signintime)) time session inner bring together pupil on session.anum = student.anum left bring together (select support.session_id, max(support.finishtime) fin back upwards grouping support.session_id) t on t.session_id = session.session_id session.status = 3

the problem comes when add together sec_to_time before timediff.

why happen?

now show guys result of query sec_to_time :

+------------+-----------+--------------+----------------+--------+----------+ | session_id | anum | first | lastly | why | time | +------------+-----------+--------------+----------------+--------+----------+ | 220 | b00000000 | testing | thisout | other | 00:12:21 | +------------+-----------+--------------+----------------+--------+----------+ 2 rows in set (0.00 sec)

any explanation lovely.

00:07:41 = 741 seconds = 00:12:21 how sec_to_time sees it. function takes number of seconds , converts format h:m:i. have h:m:i, makes no sense utilize sec_to_time here.

mysql datetime select

No comments:

Post a Comment