The problem is checking against all dates already in the DB. To avoid that I would have another table with the max(to_dates) and min(from_dates) of all DB values, those will be updated with each new insert if required.
Why those values? to avoid any overlaps, then your new values must be such that to_date < min(from_dates) and from_date > max(to_dates) plus the obvious from_date <= to_date You can compare datetime.date objects with the regular comparison operators, e.g. date1 < date2 On Feb 25, 3:00 pm, Jonathan Lundell <[email protected]> wrote: > On Feb 25, 2011, at 11:23 AM, greenpoise wrote: > > > > > exactly, no overlapping date ranges > > If I were doing it, I think I'd start with a (renamed) copy of > gluon.validators.IS_NOT_IN_DB in my model file, and change it to do a range > check on two fields, instead of an equality check on one. > > I'm sort of fuzzy on how you do date comparisons, but presumably there's a > way. > > > > > On Feb 25, 11:14 am, Jonathan Lundell <[email protected]> wrote: > >> On Feb 25, 2011, at 11:01 AM, greenpoise wrote: > > >>> How could I combine these two? I have a table that accepts two dates. > >>> I would not like duplicates between in those entry dates. > > >>> Basically a From Date and a To Date > > >> So the restriction is essentially: no overlapping date ranges in the > >> database? > > >>> Thanks > > >>> Dan > >

