When I try the following in the Query Editor of the Developer Console:
SELECT WhoID, COUNT(Id), MIN(ActivityDate), MAX(ActivityDate)
FROM Task
GROUP BY WhoID
LIMIT 1000
I get the following error:
SELECT WhoID, COUNT(Id), MIN(ActivityDate), MAX(ActivityDate)
^
ERROR at Row:1:Column:30
field ActivityDate does not support aggregate operator MIN
One would think that, given that Task.ActivityDate
is a field of type Date, it should be possible to calculate the minimum/maximum value.
Actually, according to Salesforce's documentation on Support for Field Types in Aggregate Functions, the use of MIN()
and MAX()
with DateTime is allowed.
At least I know I am not alone, there is a post in Ideas about it.
Any idea on how I can make this work?
ActivityDate
is of type Date but your question is still a good one!ActivityDate
appears as "Date/Time". I went by that instead of opening the object in the Developer Console. Amended.