> I got a mysql database, where two of the fields of a table > record times as > CHAR(8) in the format hh:mm:ss
This is one of those situations where having your database using the most appropriate field types would help. When you've got it as CHAR there's little you can do in the way of comparisons in sql. It's probably as good a time as any to create a new column of type 'TIME' and then create yourself a short php script to read in all your char-based times and write them back to the database as time-type times. Once you've done this you can use native MySQL time and date calculations to do all the hard work for you. > I want to take this two times and get the difference between > them in seconds, for example 12:01:30 - 12:00:00 = 90 I > looked up at the doc in the php.net website and couldn't get > on how to do this... should I use the strtotime function? If you have some particular reason why you can't convert your columns to time then you'll need to do some work on converting time formats in php instead - this will most likely end up being more processor intensive for any significant iterations of the calculations involved. > anyone has donde something like this, or knows what > functions could help me to do this? Mostly just using the right field types in sql to start with and then using the wealth of functions available to you. CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php