EchoFool Posted March 19, 2008 Share Posted March 19, 2008 I have a query which gets the days of a date field .. but i need it to do minutes... how is this done? This is my query: $GetHospital = mysql_query("SELECT DATEDIFF(NOW(), `When`) As BeenIn FROM hospital WHERE UserID='{$_SESSION['Current_User']}'") Or die(mysql_error()); When i echo Row['BeenIn']; I get an echo of 1 because its 1 day, even though really it should be in minutes so it would be like 9 minutes or some thing like that... how can i do this? Link to comment https://forums.phpfreaks.com/topic/96810-query-to-go-by-minutes-not-days/ Share on other sites More sharing options...
jeremyphphaven Posted March 19, 2008 Share Posted March 19, 2008 using the wrong MYSQL function. Use date_add or date_sub and you can specify how you get it returned to you... See specifics here - http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_datediff Link to comment https://forums.phpfreaks.com/topic/96810-query-to-go-by-minutes-not-days/#findComment-495443 Share on other sites More sharing options...
teng84 Posted March 19, 2008 Share Posted March 19, 2008 use TIMEDIFF() Link to comment https://forums.phpfreaks.com/topic/96810-query-to-go-by-minutes-not-days/#findComment-495445 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.