LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-23-2004, 07:45 AM   #1
buttersoft
Member
 
Registered: Aug 2003
Distribution: Slackware
Posts: 178

Rep: Reputation: 30
MSQL and Time records


Can someone put me out of my current misery, despite having 1 MySQL book to leave through I cannot add these three records, I want to see the answer displayed as 01:30:00 (i.e sum of t1 - displayed in time format) which everyone understands as 1 hour 30 minutes :-

The field t1 is of type TIME

mysql> select * from time_val;
+----------+
| t1 |
+----------+
| 00:30:00 |
| 00:30:00 |
| 00:30:00 |
+----------+
3 rows in set (0.00 sec)

I don't understand this result at all:-
mysql> select sum(t1) from time_val;
+---------+
| sum(t1) |
+---------+
| 9000 |
+---------+
1 row in set (0.00 sec)

Here the records are displayed correctly in seconds:-
mysql> select time_to_sec(t1) from time_val;
+-----------------+
| time_to_sec(t1) |
+-----------------+
| 1800 |
| 1800 |
| 1800 |
+-----------------+
3 rows in set (0.00 sec)

Can anyone please put me on the right track?

***************************************************************************

I solved it for myself by changing the t1 data to a number and recording there only the minutes taken - no seconds - no hours just minutes.

Then the line below gives me what I now find acceptable for my result which is number of hours rounded.


select round(sum(t1*60)/3600) AS Hours_Spent from static;


Last edited by buttersoft; 03-23-2004 at 08:24 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
msql driver problem cptnchainsaw Linux - General 4 05-05-2005 04:38 PM
Where to find my msql db r0ck Slackware 8 12-23-2004 04:39 PM
msql and hostname problems krayz1e Linux - Newbie 4 09-04-2004 01:48 AM
msql bm1 Slackware 2 02-05-2004 12:18 AM
msql++ c++ api for mysql nakkaya Linux - Software 0 04-19-2003 03:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration