Reputation: 26655
Please correct me if I'm wrong, but I've concluded that the following gets yesterday's data:
....filter('modified >', datetime.datetime.now() - timedelta(days=2)).filter('modified <', datetime.datetime.now() - timedelta(days=1)).fetch(9999999))
Is there a better way?
Upvotes: 1
Views: 46
Reputation: 59175
That will give you all the data modified between 48 hours ago and 24 hours ago.
When you mean 'yesterday', do you want to get data for the previous day (marked between midnights), or a moving window as in the given code?
You don't need to specify fetch(999999), as fetch() will bring all the data available (a different strategy might be a good idea, if retrieving too much data).
How about:
import datetime
now = datetime.datetime.now()
today = datetime.datetime(now.year, now.month, now.day)
yesterday = today - datetime.timedelta(days=1)
....filter('modified >', yesterday).filter('modified <', today).fetch()
Upvotes: 3