At 13:35 -0800 3/4/02, Nathan Cowles wrote: >Paul, > >You're awesome...thank you. One more question pertaining to this... > >I'm accustomed to selecting a variable and using something like this: > >$firstin = mysql_result($result,$row,firstin); > >to set my variable. > >What do I want to do here to get the right result into my variable? > >$query2 = "SELECT SEC_TO_TIME(TIME_TO_SEC('$lastout') - >TIME_TO_SEC('$firstin'))"; >$result2 = mysql_db_query($database, $query, $connection) or die >("Error in query: $query. " . mysql_error()); > >This isn't working, I get 23: > >$total = mysql_result($result2,0);
I guess it depends on what the values of $firstin and $lastout are, and how you're displaying the value of $total. It's hard to say anything without seeing more of the code. > >Thanks again! > >Nathan Cowles > >On Mon, 4 Mar 2002, Paul DuBois wrote: > >> >Hello, >> > >> >I am trying to get an accurate (nearest 15 minutes would be >> >fine) difference between two times that I have in my database. They are >> >both of type time, and are in the format 00:00:00. >> > >> >For example, if I want the difference between 09:20:00 and 10:43:00, I >> >would like it to give me 01:23:00 as the answer, but all I have been able >> >to get it to do is give me one. It is rounding to the nearest hour. >> > >> >I found this query which seems like it would work, but gives me a NULL >> >result set: >> > >> >SELECT DATE_SUB('11:48:02', INTERVAL '10:37:37' HOUR_SECOND); >> >> For two times t1 and t2, compute the difference in seconds like this: >> >> SELECT TIME_TO_SEC(t2) - TIME_TO_SEC(t1) >> >> If you want the result as a time value, pass it to SEC_TO_TIME(): >> >> SELECT SEC_TO_TIME(TIME_TO_SEC(t2) - TIME_TO_SEC(t1)) >> >> >> > >> >I am trying to do all of this from PHP, so if you happen to know of a way >> >to make it do the subtraction in PHP without losing all accuracy, please >> >let me know. >> > >> >Thanks for any help you can offer. >> > >> >Nathan Cowles >> >StormNet Communications >> >530.897.4069 >> > >Nathan Cowles >StormNet Communications >530.897.4069 --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php