check again on a fresh app. you're doing something wrong
db.define_table('mydates', Field('value'), Field('valuedate', 'date'))
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.
mydates.valuedate) # Select the dates in Database
mindate = db.mydates.valuedate.min()
maxdate = db.mydates.valuedate.max()
start = db(db.mydates.valuedate).select(mindate) # Start Date
finish = db(db.mydates.valuedate).select(maxdate) # finish Date
finish = finish.first()[maxdate]
start = start.first()[mindate]
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()
--
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.