6

I am trying to retrieve opportunities created between 01-01-2011 and 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

since createdate is a datetime i get a error saying createdDate is datetime and should not be enclosed in quotes.

Can someone help on how to get this query working. I just want this query to get it running in apex explorer, this is not part of apex code

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
Prady
  • 10,978
  • 39
  • 124
  • 176

1 Answers1

11

SOQL query to retrieve opportunities between two dates:

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 
Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Prady
  • 10,978
  • 39
  • 124
  • 176