views:

49

answers:

1

I'm trying to understand how I can use the local server time to quickly filter results on google appengine. It seems to me that there should be a simple way of doing this using DATETIME(time.localtime()).

For example (where 'timestamp' is of type db.DateTimeProperty)...

q = db.GqlQuery("SELECT * FROM LiveData WHERE timestamp > DATETIME(:1)", time.localtime())

Is there a GqlQuery and/or python construct that lets me do this with one method call? It seems as though I need to create strings for DATETIME() parameters.

+2  A: 

You do not have to create strings when querying DateTimeProperty types. Try this:

import datetime
q = db.GqlQuery("SELECT * FROM LiveData WHERE timestamp > :1", datetime.datetime.now())
David Underhill