Reputation: 1279
Given the following entity:
class DateTest(db.Model):
dateAdded = db.DateTimeProperty()
#...
What would be the best way to get the records from the current month?
Upvotes: 2
Views: 611
Reputation: 9183
There are a few ways you can do this. For example, using Query
:
import datetime
from google.appengine.ext import db
q = db.Query(DateTest)
# This month
month = datetime.datetime.today().replace(day=1, hour=0, minute=0, second=0, microsecond=0)
q.filter('dateAdded >= ', month)
results = q.fetch(10)
Upvotes: 7
Reputation: 1418
You could try something like:
import datetime
now = datetime.datetime.now()
DateTest.gql("WHERE dateAdded.month:1", now.month)
Upvotes: 1