My task has a simple one, just to find the missing days in a given interval 
of my database.

db_define('mydates', Field('value'), Field('valuedate', 'date')

in the controller : 

import datetime 

def date_range(start, end):
    r = (end+datetime.timedelta(days=1)-start).days
    return [start+datetime.timedelta(days=i) for i in range(r)]

def calc_missing():
    mydates = db(db.mydates).select(db.mydates.valuedate, orderby = 
db.daily.indate) # Select the dates in Database
    start = db(db.mydates.valuedate).select(db.mydates.valuedate.min()) # 
Start Date 
    finish = db(db.mydates.valuedate).select(db.mydates.valuedate.max()) # 
finish Date
    finish = finish[0]['_extra'] ['MAX(mydates.valuedate)']
    start =  start[0]['_extra'] ['MIN(mydates.valuedate)']
    real_dates = date_range(start, finish) # Find the real_dates, a 
synthetic date dateset 
    missing_dates = set(real_dates).difference(mydates) # find missing days
    mydates_len = len(mydates)
    myreal_len = len(real_dates)
    return locals()


After running this, i get mydates and real_dates lenght the same!!!  even 
that i have define  my table field to be 'date' .
So, 'date'  in table field is not a datetime object? In order to make a 
simple  set(real_dates).difference(mydates) i must first covert the field 
'date' to a datetime structure? If yes, that is the point of a field 
'date'? only to display in form , a calendar input?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to