Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9257505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:10:29+00:00 2026-06-18T12:10:29+00:00

I was testing out queries to make sure that they were giving back proper

  • 0

I was testing out queries to make sure that they were giving back proper results. However I noticed that I was getting the wrong time. One of my timestamps is

2013-02-07 07:26:04

and I subtract :

2013-02-07 07:18:23

from the first time stamp

and that was giving me a difference of twelve or so minutes. Now I’m not a math genius but I can even say that 18 – 12 = 6… not 12… so I knew there was a problem with the query. So I removed the SEC_TO_TIME and it gave me the correct time diff of :

+------------+-----------+--------------+----------------+--------+----------+
| session_id | anum      | first        | last           | why    | time     |
+------------+-----------+--------------+----------------+--------+----------+
|        220 | B00000000 | Testing      | thisout        | Other  | 00:07:41 |
+------------+-----------+--------------+----------------+--------+----------+


This is my query now : 


SELECT 
session.session_id, 
session.anum, 
student.first, 
student.last, 
session.why,
(TIMEDIFF(t.fin, session.signintime)) AS time 
FROM session 
INNER JOIN student 
    ON session.anum = student.anum  
LEFT JOIN (SELECT support.session_id, MAX(support.finishtime) AS fin FROM support GROUP BY support.session_id) AS t  
    ON t.session_id = session.session_id 
WHERE session.status = 3 

The problem comes when I add the SEC_TO_TIME before the TIMEDIFF.

Why does this happen?

Now just to show you guys the result of the query with SEC_TO_TIME :

+------------+-----------+--------------+----------------+--------+----------+
| session_id | anum      | first        | last           | why    | time     |
+------------+-----------+--------------+----------------+--------+----------+
|        220 | B00000000 | Testing      | thisout        | Other  | 00:12:21 |
+------------+-----------+--------------+----------------+--------+----------+
2 rows in set (0.00 sec)

Any explanation would be lovely.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:10:30+00:00Added an answer on June 18, 2026 at 12:10 pm

    00:07:41 = 741 seconds = 00:12:21 is how SEC_TO_TIME sees it. The function takes a number of seconds and converts format it as h:m:i. You already have it as h:m:i, it makes no sense to use SEC_TO_TIME here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am testing out a property system and I want to make sure that
In testing out our API, one of our testers found out that when they
I've had some bizarre results from queries I've been testing out with the DATE
Testing out someone elses code, I noticed a few JSP pages printing funky non-ASCII
I'm testing out CouchDB to see how it could handle logging some search results.
Having a weird problem. I'm testing an ASP.NET application I wrote that queries SQL
when testing out our machine for apache or SVN, i found that we can
I'm testing out a basic Rails app and I seem to be getting some
I want to make sure I am testing Models/Objects in isolation and not as
After testing out instasnceof I found that it will return true if the argument

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.