On Mon, May 16, 2011 at 10:42 AM, Jorge Romero <jorgeromero...@gmail.com> wrote: > Hi Pythonists, > I'm retrieving some time data from a MySQL database using Python's MySQLdb > library. Here's the situation, I got a time field on MySQL given in seconds, > I need it on HH:MM:SS format, so I'm SELECTING that field with SEC_TO_TIME > function, something like this: > query = "SELECT SEC_TO_TIME(SUM(seconds)) FROM table"
You're summing a column, so presumably the values are actually deltas (it doesn't make sense, for instance, to add Tues March 16th to Sat Nov 2nd). The result exceeds a day; in what format do you actually want it? For maximum flexibility, you could ditch the SEC_TO_TIME call and simply work with the integer seconds in Python. You can then format that into HHHHH:MM:SS or whatever suits you. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list