Skip to content

Instantly share code, notes, and snippets.

@torufurukawa
Created January 12, 2012 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torufurukawa/1598658 to your computer and use it in GitHub Desktop.
Save torufurukawa/1598658 to your computer and use it in GitHub Desktop.
GAE DateTimeProperty index
from datetime import datetime, timedelta
from google.appengine.ext import db
class Foo(db.Model):
value = db.DateTimeProperty()
db.delete(Foo.all())
Foo(value=None).put()
Foo(value=datetime.now()).put()
Foo(value=datetime.now()).put()
print Foo.all().count() # 3
print Foo.all().filter('value >', datetime.now()-timedelta(minutes=1)).count() # 2
print Foo.all().filter('value <', datetime.now()).count() # 3
print Foo.all().filter('value =', None).count()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment