ian wrote: > Hi, > > i have a problem with time in python. > > 1) i got 2 values from mysql db (fields are "time" type) > 2) python get it as "<type 'datetime.timedelta'>" (why timedelta???)
timedelta because a time doesn't represent a fixed point until it's associated with a date, I presume. > 3) i need to compare 2 fields with actual time ... EG: > if ArrOutputsAuto[i].TimeFrom >= GNow and ArrOutputsAuto[i].TimeTo <= GNow: > > i need actual time, and 2 fields from DB in datetime.time type (correct me > if i'm wrong) so i can do my test "if time>= ..." > > I think i can grab time from DB in string and parse it in > datetime.time(x,x,x) but its not very optimized > > Any idea ? > Presumably the datetime.timedelta object comes back from the database with days=0? In which case try something like import time import datetime dbtd = <timedelta from database> h, m, s = time.localtime()[3:6] timenow = s + (60 * (m + 60 * h)) Then compare timenow with dbtd.seconds. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list