|
From: Neil Blakey-M. <nb...@mi...> - 2004-06-02 12:14:17
|
On Wed 2004-06-02 (14:05), Philippe Normand wrote:
> I see one durty solution which would like this (untested) :
>
> calendar = {} # keys: day numbers of the month
> for article in Article.select(orderBy=Article.q.date):
> if article.getYear() != 2004 or article.getMonth() != 5:
> continue
> try:
> calendar[article.getDay()] += 1
> except KeyError:
> calendar[article.getDay()] = 1
>
>
> it isn't really efficient because it fetches all articles. Is there a clean
> way to select SQLObjects given a specific date interval on DateTimeCol ?
I just compare them to a datetime, and that works just fine for me.
Although, there's a bug where the datetime conversion uses '%s' instead
of '%S' for seconds, which probably wouldn't affect your usage.
a = sql.table.acct
if start_date:
criteria.append(a.stamp_inserted >= start_date)
if end_date:
criteria.append(a.stamp_inserted < end_date)
Neil
--
Neil Blakey-Milner
nb...@mi...
http://mithrandr.moria.org/
|