Special Date calculation

Hello, I REALLY need some help creating a special date calculation. I want to calculate the difference between 2 mysql fields but display the difference as:
//
//
02:19:21
//
02 is days
19 is hours
21 as minutes
//
//
$Dater01 = $row[‘tblTabler00_Dater01’]; //2010-12-16 23:45:00
$Dater02 = $row[‘tblTabler00_Dater02’]; //2010-12-14 04:24:00
//
$Dater03 = $Dater01 - $Dater02
//
Important is that a negative amount is valid, meaning it is overdue. Any help would be greatly appreciated.
//
Regards,

Holle …
try this

$Dater01 = mktime($row[‘tblTabler00_Dater01’]:wink: //2010-12-16 23:45:00
$Dater02 = mktime($row[‘tblTabler00_Dater02’]:wink: //2010-12-14 04:24:00

$Dater03 = $Dater01 - $Dater02;

You could do that operation in your database.


select
(day('2010-12-16 23:45:00') -  day('2010-12-14 04:24:00')) as days_diff,
(hour('2010-12-16 23:45:00') - hour('2010-12-14 04:24:00')) as hrs_diff,
(minute('2010-12-16 23:45:00') - minute('2010-12-14 04:24:00')) as mins_diff
 ;

days_diff | 2
hrs_diff | 19 
mins_diff | 21

Just swop actual values for field names such as tblTabler00_Dater01 and add your where clauses.

Posting this in case there is a more elegant way of doing the SQL query so I learn something too… :slight_smile:

no, it looks fine, except for the unnecessary extra parentheses :slight_smile: