appengine select基于时间戳

bob*_*obo 2 python google-app-engine

我似乎无法根据时间戳选择一些东西.行为有点奇怪,<和=符号似乎并不意味着我期望它们.

""" A site message """
class Message( db.Model ) :
  # from/to/ a few other fields
  subject = db.StringProperty()
  body = db.Text()

  # this is the field i'm trying to use
  sent = db.DateTimeProperty( auto_now_add=True )

当我写GQL查询时

select * from Message where sent = '2009-09-14 01:00:02.648000'

(在数据存储区中有一条准确显示该时间戳的消息)

没有给我任何回报.

如果我试试

select * from Message where sent < '2009-09-14 01:00:02.648000'

它只是给了我所有这些.当我尝试>符号时,它只是再次给我一个.

这里发生了什么,我如何根据时间戳选择?

Ale*_*lli 5

千万不要使用字符串为"站队"的日期时间!它不会起作用......

请参阅docs:DateTimeProperty对应于datetime.datetime值. import datetime,将您心爱的字符串转换为datetime.datetime实例(例如,通过调用其strptime方法),使用THOSE实例进行比较 - 当然,从此过上幸福的生活! - )