ik heb een lijst met tijden uur, minuten, seconden. bv. 16.16.16
ik heb een tijd bv. 16.00.00
ik wil dus dat 16.00.00 wordt afgetrokken van 16.16.16 zodat ik uiteindelijk 00.16.16 uitkomt. Ik wil dit echter doen voor 200 tijden. Is dit het gemakkelijkst met date_add en kan die wel seconden aan?

vriendelijke groeten, tommy

opmerking: tijden zitten in tabel in phpmyadmin (db) dus...:)
Ik zou eerder in de richting van TIMEDIFF zoeken. Je format met puntjes is wel gek. Meestal zijn het dubbele punten, dus: 16:16:16
verstrooi..foutje srry eff aanpassen
TIMEDIFF? eff kijken en wat doet die functie

edit:
TIMEDIFF(expr,expr2)

TIMEDIFF() returns the time between the start time expr and the end time expr2. expr and expr2 are time or date-and-time expressions, but both must be of the same type.

mysql> SELECT TIMEDIFF('2000:01:01 00:00:00',
-> '2000:01:01 00:00:00.000001');
-> '-00:00:00.000001'
mysql> SELECT TIMEDIFF('1997-12-31 23:59:59.000001',
-> '1997-12-30 01:01:01.000002');
-> '46:58:57.999999'
Wat doet die functie? Precies wat jij wilt :-)

TIMEDIFF( )
TIMEDIFF(time, time)
This function returns the time difference between the two times given. Although the
arguments may be given in time or date-and-time format, both arguments must be of
the same datatype. This function is available as of Version 4.1.1 of MySQL.
SELECT appointment AS Appointment, NOW( ) AS Now,
TIMEDIFF(appointment, NOW( )) AS 'Time Remaining'
FROM appointments
WHERE rec_id='3783';
+--------------------+--------------------+----------------+
| Appointment | Now | Time Remaining |
+--------------------+--------------------+----------------+
| 2005-01-11 10:30:00| 2005-01-11 22:28:09| 12:01:51 |
+--------------------+--------------------+----------------+
okay leuk en bedankt
nog een probleem de tijden zitten in een andere tabel:

duathlon: id, (aftetrekken)tijd
instellingen: tijd
Je kunt een query over meer dan 1 tabellen laten lopen.

SELECT TIMEDIFF(tabel1.tijd, tabel2.tijd) AS verschil
FROM tabel1, tabel2
$sql = "SELECT TIMEDIFF(instellingen.start_time,duathlon.tijd) AS time FROM instellingen, duathlon";
$query = mysql_query($sql)or die(mysql_error());

waren typfouten, :p

AS ... wat betekend dat eigenlijk, wat zijn alliasen eigenlijk?
$sql = "SELECT TIMEDIFF(instellingen.start_time,duathlon.tijd) AS tijd FROM instellingen, duathlon";
$query = mysql_query($sql)or die(mysql_error());
while ($list = mysql_fetch_object($query)){
echo $list->tijd;
}

dit werkt niet ?
Wat zegt de error?
geen error; alleen geen output

Heb nogal mijn twijfels over wat ik moet invullen na de AS dus dat zou wel eens het probleem kunnen zijn.
groeten, tommy

tabel structuur
->duathlon
+----------------+--------------------+---------------+
| id | schoolnummer | tijd |
+----------------+---------------+---------------+
| 1 | 409 | 16:12:33 |
+----------------+---------------+---------------+
->instellingen
+----------------+---------------+
| start_time | total_time |
+----------------+---------------+
| 16:00:00 | hier moet dus komen 00:12/33
+----------------+---------------+

als ik de code $sql = "SELECT TIMEDIFF(duathlon.tijd,instellingen.start_time) AS total_time FROM instellingen, duathlon";
invoer in de sql van phpmyadmin kom ik 10 keer NULL uit

Reageren