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...:)
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.
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 |
+--------------------+--------------------+----------------+
$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;
}
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