+ Start a Discussion
Alexandra StehmanAlexandra Stehman 

Error finding Tasks related to Opportunities with CreatedDate Range: No such column on Entity 'Name'?

Select Id FROM Task 
 where What.RecordType.SObjectType='Opportunity' and
(What.CreatedDate >2015-05-23T11:59:59Z and What.CreatedDate <2015-05-25T00:00:00Z)
That is the query I am using. It seems fairly straightforward to me that only related entities of type Opportunity should be returned.

However, both DataLoader and DeveloperConsole return this error:

What.CreatedDate>2015-05-23T:11:59:59Z
^
ERROR at Row:3:Column:2
No such column 'CreatedDate' on entity 'Name'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name...."

Where am I goofing up?

THANK YOU!
Best Answer chosen by Alexandra Stehman
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
Select Id FROM Task 
 where whatid IN (select Id From Opportunity where 
CreatedDate >2015-05-23T11:59:59Z and CreatedDate <2015-05-25T00:00:00Z)

Please try this if you are trying to retrieve task with opportunity createdDate range

All Answers

Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
Select Id FROM Task 
 where whatid IN (select Id From Opportunity where 
CreatedDate >2015-05-23T11:59:59Z and CreatedDate <2015-05-25T00:00:00Z)

Please try this if you are trying to retrieve task with opportunity createdDate range
This was selected as the best answer
Alexandra StehmanAlexandra Stehman
Thank you, Ashwin!

Do you know the reason why the first query doesn't work? (I come from an RDBMS background, which I've found hurts as much as it helps in the SFDC world)
Ashwin Kumar SrinivasanAshwin Kumar Srinivasan
I am not sure if this link will help you with an explanation http://www.tgerm.com/2010/11/no-such-column-on-entity-error.html please try. Thanks!