Hi,
how can i get the SUM of a TIME field without using TIME_TO_SEC()?
example:
SELECT
SUM(`my_time`)
FROM
`table`
GROUP BY
`id`
returns: 765
some completely wrong result, not formated in as TIME
SELECT
SEC_TO_TIME(SUM(TIME_TO_SEC(`my_time`)))
FROM
`table`
GROUP
I think there should be no problem to use the SUM() function - did you tried
it like this
select SEC_to_time(SUM(unix_timestamp(TTendTime) -
unix_timestamp(TTstartTime))) as endtime
FROM TimeTracking
WHERE TTperson = 1 and date(TTstartTime) = '2005-10-19'
HTH
--
Dobromir Velev
[EMAIL
[EMAIL PROTECTED] wrote on 10/24/2005 12:48:32 AM:
I have a table doing time tracking. I don't use timestamps, I use
datetime fields to record punch in times and punch out times. I
have this query that computes the amount of time between a punch in
and punch out:
select
I have a table doing time tracking. I don't use timestamps, I use
datetime fields to record punch in times and punch out times. I
have this query that computes the amount of time between a punch in
and punch out:
select SEC_to_time(unix_timestamp(TTendTime) -
Martijn Tonies wrote:
I have a table doing time tracking. I don't use timestamps, I use
datetime fields to record punch in times and punch out times. I
have this query that computes the amount of time between a punch in
and punch out:
select SEC_to_time(unix_timestamp(TTendTime) -
Michael Stassen wrote:
snip
Second, no, it won't overflow:
mysql SELECT SEC_TO_TIME(60*60*24*5);
+-+
| SEC_TO_TIME(60*60*24*5) |
+-+
| 120:00:00 |
+-+
1 row in set (0.00 sec)
mysql SELECT
This translated to SQL as:
select SEC_to_time(SUM(unix_timestamp(TTendTime)) -
SUM(unix_timestamp(TTstartTime)))
as endtime
FROM TimeTracking
WHERE TTperson = 1
and date(TTstartTime) = '2005-10-19'
Won't this fail if it overflows 24 hours?
Given that the result of SEC_TO_TIME
Michael Stassen wrote:
snip
Second, no, it won't overflow:
mysql SELECT SEC_TO_TIME(60*60*24*5);
+-+
| SEC_TO_TIME(60*60*24*5) |
+-+
| 120:00:00 |
+-+
1 row in set (0.00 sec)
Martijn Tonies [EMAIL PROTECTED] wrote on 10/24/2005 10:16:21 AM:
Michael Stassen wrote:
snip
Second, no, it won't overflow:
mysql SELECT SEC_TO_TIME(60*60*24*5);
+-+
| SEC_TO_TIME(60*60*24*5) |
+-+
| 120:00:00
On Mon, 24 Oct 2005 [EMAIL PROTECTED] wrote:
Martijn Tonies [EMAIL PROTECTED] wrote on 10/24/2005 10:16:21 AM:
Michael Stassen wrote:
snip
Second, no, it won't overflow:
mysql SELECT SEC_TO_TIME(60*60*24*5);
+-+
|
I have a table doing time tracking. I don't use timestamps, I use datetime
fields to record punch in times and punch out times. I have this query that
computes the amount of time between a punch in and punch out:
select SEC_to_time(unix_timestamp(TTendTime) - unix_timestamp(TTstartTime))
as
i dont think its possible. you can do it by using time_to_sec() function of
mysql and then sec_to_time after addition
Hope that helps
Nitin
- Original Message -
From: Elly Wisata [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 19, 2004 10:08 AM
Subject: Sum for time
Hi
Hi *,
Can somebody show me how to sum for time, my format is hh:mm:ss, need to do
sum for the time as we usually sum a field with integer type. But I am not
sure sum can use for time format.
Thanks in advance
~Elle~
13 matches
Mail list logo