Guru
Guru

Reputation: 148

Google App Engine GQL Query - Date Query without year

I have a problem with making a GQL query to fetch dates without year. Basically, my data set consists of data of many years and I am trying to find the data for same date over many years.

How do I do that using GQL?

All help appreciated.

Upvotes: 2

Views: 75

Answers (1)

Greg
Greg

Reputation: 10360

You need to store month+day as a property, then query against that. With NDB, a ComputedProperty can make this easier:

class Model(ndb.Model):
  date_field = ndb.DateTimeProperty()
  month_day = ndb.ComputedProperty(lambda self: '%s-%s' % (self.date_field.month, self.date_field.day)

Upvotes: 4

Related Questions