[SalesForce] SOQL to get all Leads that were created on particular date or range

I am trying to a REST call from java and trying to query LEAD entity to get all Leads that were created on a particular date/date range. I am unable to get working query for the same.

I am doing something like this:

HttpGet get = new HttpGet(loginInstanceUrl+ "/services/data/v33.0/query?q=Select+Id+,+FirstName+,+LastName+,+Company+From+Le‌​‌​ad");

This gives me list of all Leads. I tried adding a where clause here something like Where CreateDate=3/25/2015 but then query fails with CreateDate is not a column on Lead Entity.

Best Answer

The name of the field isn't CreateDate but CreatedDate.

The following query will, in example query all leads which were created in the current year:

SELECT id, firstname, lastname, company, CreatedDate 
FROM Lead 
WHERE CreatedDate = THIS_YEAR


/services/data/v29.0/query?q=SELECT+id,+firstname,+lastname,+company,+CreatedDate+FROM+Lead+WHERE+CreatedDate+=+THIS_YEAR
Related Topic