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

  • Home
  • SEARCH
  • 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 7694175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:15:34+00:00 2026-05-31T21:15:34+00:00

I have a Mysql table that stores dates in the format (YYYY-MM-DD HH:MM:SS). What

  • 0

I have a Mysql table that stores dates in the format (YYYY-MM-DD HH:MM:SS).

What i want is to SUM the HH:MM:SS part for the selected rows, so as i found in another post i use the query

SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(date))) FROM table

This query works. It sums the part that i want and returns it in the format HH:MM:SS.

My question is if its possible to strip of the seconds from the result.

I have to do this in the query, as the CMS that i use doesn’t allow me to use php on this part.

By the way it would be amazing if i could return the result in days, hours and minutes in case the sum is greater that 24 hours.

Thanks in advance

For anyone interested i found the solution

SELECT TIME_FORMAT(SEC_TO_TIME(SUM(TIME_TO_SEC(hours))),'%H:%i' ) FROM table
  • 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-05-31T21:15:35+00:00Added an answer on May 31, 2026 at 9:15 pm

    Try this query, it will calculate days, hours and minutes –

    SELECT
      SUM(TIME_TO_SEC(date) DIV 86400) days,
      SUM(EXTRACT(HOUR FROM (SEC_TO_TIME(TIME_TO_SEC(date) % 86400)))) hours,
      SUM(EXTRACT(MINUTE FROM (SEC_TO_TIME(TIME_TO_SEC(date) % 86400)))) minutes
    FROM table
    

    Then use CONCAT function to format these result into one string.

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

Sidebar

Related Questions

I have mysql table that has a column that stores xml as a string.
I have a high scores table that stores a list of scores and dates.
I have an ecommerce MySQL database that stores order information in the table 'orders'
I have a table (MySQL) data that stores a bunch of signup information. What
I've have a date field in my table that stores dates from a form
I have a MSSQL table stores that has the following columns in a table:
Ok I have a table in my SQL Server database that stores comments. My
I have a mysql table that relies on the unix epoch time stamp equivalent
I have a MySQL table that will only have one row. What should my
I have a MySQL table that holds many entries with repeated IDs (for various

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.