Question

I tried just using the date's string representation but it didn't work (i.e. no results):

gql = "SELECT * from Shout where when='2010-11-05 16:57:45.675612'"

This is my Shout class:

class Shout(db.Model):
   message= db.StringProperty(required=True)
   when = db.DateTimeProperty(auto_now_add=True)
   who = db.StringProperty()
Was it helpful?

Solution

gql = "SELECT * FROM Shout WHERE when = DATETIME('2010-11-05 16:57:45')"

Per documentation, use the following for date/time literals:

  • DATETIME() with timestamps,
  • DATE() with dates,
  • TIME() with times

An alternative syntax is:

SELECT * FROM Shout WHERE when = DATETIME(2010,11,5,16,57,45)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top