Soql查询以检索两个日期之间的机会

时间:2011-07-12 07:09:28

标签: salesforce soql

我正在尝试检索在01-01-2011和06-30-2011之间创建的机会。

Select o.CreatedDate, o.Id, o.LastModifiedDate
from Opportunity o 
where   o.CreatedDate > '1/1/2011' and o.CreatedDate <  '12/31/2011'
order by  o.LastModifiedDate

因为createdate是一个日期时间我得到一个错误,说创建日期是日期时间,不应该用引号括起来。

有人可以帮助您了解如何使此查询正常工作。我只是想让这个查询在apex资源管理器中运行,这不是顶点代码的一部分

1 个答案:

答案 0 :(得分:10)

SOQL查询以检索两个日期之间的机会:

Select o.CreatedDate, o.Id, o.LastModifiedDate 
from Opportunity o 
where   o.CreatedDate > 2011-01-01T00:00:00Z and o.CreatedDate < 2011-12-31T00:00:00Z 
相关问题