Portal Home > Knowledgebase > Articles Database > SQL/Mysql Expert please!
Posted by DomiNET.net, 06-02-2007, 08:14 AM 1) I have a table with two DATE fields (call_start,call_end). 2) Usually both fields have same DATE but different time. 3) I can calculate how many minutes in difference has both fields with: SELECT TIMEDIFF(call_end,call_start) 4) The result is supposed to be a DATE COLUMN Question: How to round the result? if i get a result of 05:42 (5 minutes and 42 seconds) i want to round to 06:00. how to round time? regards
Posted by WO-Jacob, 06-02-2007, 03:58 PM First I suppose you mean DATETIME as DATE would just have the date. Here's my initial thought: SELECT CONCAT(ROUND(UNIX_TIMESTAMP(call_end) - UNIX_TIMESTAMP(call_start) / 60), ':00') as timeDiff would populate 'timeDiff' to be 6:00 in your example, or you could simply leave it at rounded minutes and have your client-side handle the display of the information which would probably be preferable. Just take off the concat.
Add to Favourites Print this Article