I would suggest using TIMESTAMPDIFF
instead of DATEDIFF
as DATEDIFF
only considers the date components and not the time.
SELECT SUM(total * TIMESTAMPDIFF(DAY, pickupdt, returndt) + 1)
...
For example:
SELECT TIMESTAMPDIFF(DAY, '2014-01-01 08:00:00', '2014-01-02 12:00:00') + 1;
would yield an integer value of 2 indicating that the item was check out for longer than 24 hours.
The + 1
part is because the function rounds down partial days.