Quote:
|
Originally Posted by samu78nyc
timestamp(stop_date,stop_time) - timestamp(start_date,start_time).
How do I retrieve the duration in minutes from the returned duration value.
|
The returned value is a "timestamp difference", to be interpreted as follows:
digits after the decimal point: fraction of seconds (probably to be ignored)
two digits before decimal point: seconds (also ignore if just counting minutes)
two digits before that: minutes (between 00 and 59)
two digits before that: hours (between 00 and 23)
two digits before that: number of days (in a month)
two digits before that: number of months (hopefully equal to 0, otherwise difficult to use because of unequal month lengths ...)
digits before that: number of years (hopefully equal to 0, otherwise difficult to use because of leap years ...)
So you will have to calculate hours + 24 * days if result must be in hours.
Try e.g.
Code:
SELECT INT(td/1000000) * 24 +
MOD(INT(td/10000), 100) AS hours,
MOD(INT(td/100), 100) AS minutes
FROM (SELECT timestamp(stop_date,stop_time)
- timestamp(start_date,start_time) AS td FROM tbl) AS x
where I'm assuming that there's not more than a month difference between the dates.