python - How can I query objects with a date field, using a specific month and year? -
I need to create a GCL query against the set of some objects, in which there is a date field. I for Python and GAE I'm a bit strong on this because I'm looking into the documentation but I can not find what I'm looking for. Basically I have created the following class method
Event.getEventsforMonth (CLS, month, year):
So I was trying to query my object The month and year of the date field falls into a specified range. I have tried to create date objects and used it for comparison, but I have not found any happiness yet.
dateto = str (year) + str (month + 1) + "01" date = string (year) + ARR (month) + "01" if month + 1 == 13: Datatio = ARR (year + 1) + "01" + "01" query = GQAQUYARY (Select "Event where date <= coding: date and date by lieutenant; =: dataeto", datatwo = data, datfom = Detofm) Return query
This method looks terrible to me, because I'm not too much Core methods I have Python with GUL query You can use the Nlain.
Any help is appreciated
Cheers,
Andrew
First, store your dates in the datestore as the date or datetime property examples.
Then, you can do something like this in your query:
def getEventsForMonth (auto, month, year): start_date = datetime.datetime (year, month, 1 ) If month == 12: end_date = datetime.datetime (year 1, 1, 1) other: end_date = datetime.da filter ('date'; = ', start_date) .Filter (' date & lt; = ', End_date) .fetch (1000)
/ pre>
Comments
Post a Comment