#135 Why use a timedelta?

MySQLdb-1.2
closed
Andy Dustman
MySQLdb (285)
5
2012-09-19
2005-05-09
Manuzhai
No

Why does the new 1.2.0 use a timedelta to return DATE
and TIME types? Makes no sense to me at all. It breaks
my application. I guess that was to be suspected, but
can someone please explain this change to me?

Discussion

  • Andy Dustman
    Andy Dustman
    2005-05-09

    Logged In: YES
    user_id=71372

    The reason is, MySQL TIME columns are a time delta:

    http://dev.mysql.com/doc/mysql/en/time.html

    " MySQL retrieves and displays TIME values in 'HH:MM:SS'
    format (or 'HHH:MM:SS' format for large hours values). TIME
    values may range from '-838:59:59' to '838:59:59'. The
    reason the hours part may be so large is that the TIME type
    may be used not only to represent a time of day (which must
    be less than 24 hours), but also elapsed time or a time
    interval between two events (which may be much greater than
    24 hours, or even negative)."

    If this is an issue for your application, it's a fairly
    simply matter of overriding the default behavior. Look
    through the help forum or user's guide for some hints on how
    to do this.

     
  • Manuzhai
    Manuzhai
    2005-05-11

    Logged In: YES
    user_id=487207

    Thanks, that actually makes a lot of sense. I fixed by
    changing the conversions table in my setup function. :)