Not sure if this is relevant, but you can do the following with datetime. >>> import datetime >>> a = datetime.datetime(2007, 12, 6, 16, 29, 43, 79043) >>> b = datetime.datetime(2011, 10, 3, 12, 0, 0, 0) >>> c = b-a >>> c datetime.timedelta(1396, 70216, 920957) >>> (c.microseconds + (c.seconds + c.days * 3600 * 24) * 10**6) / 10**6 120684616
(I have Python 2.6 at work, otherwise you can do c.total_seconds()) On Monday, March 26, 2012 1:41:09 AM UTC+2, Niphlod wrote: > > Doh, you're right. All the "datetime" api on fields are extracting, not > converting the actual value.... > At this point you can sum up years difference, month difference, etc etc > etc separately and then extract the time passed by. > ..... > duration_ye = (db.periods.end_time.year() - > db.periods.start_time.year()).sum() > duration_mo = (db.periods.end_time.month() - > db.periods.start_time.month()).sum() > duration_da = (db.periods.end_time.day() - > db.periods.start_time.day()).sum() > ..... > > This will be a "itchy" shot anyway.... even if you know that the months > difference is "1" you can't really say how many days passed.... > > Maybe at this stage is better to save unix time, that is an integer, and > proceed simply with > > duration = (db.periods.end_time - db.periods.start_time).sum() > > Or, having the application filling in the seconds elapsed when it > completes.... something like > period_to_update = db(db.periods.id==1).select().first() > start_time = period_to_update.start_time > period_to_update.update_record(end_time=request.now, > seconds_elapsed=(request.now - start_time).seconds) > > Sorry for the wrong previous advices, really, I should have tested with > all kinds of values (instead of 2012-01-01 00:00:00 and 2012-01-01 > 00:00:15). >

