You need to sign in to do that
Don't have an account?
Yaroslav Borisov
Average date
My accounts have the Date field Activity__c. How can I figure out an average date between all these Activity__c fields?
I tried to use SOQL:
[SELECT AVG(Activity__c) FROM Account WHERE Activity__c != null]
But it shows error:
field Activity__c does not support aggregate operator AVG
Date field is not supported for AVG() function. Hence you see error
Check below references for supported data types and use supported date type in SOQL.
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_agg_functions_field_types.htm
Hope above information was helpful.
Please mark as Best Answer so that it can help others in the future.
Thanks,
Hi Yaroslav Borisov,
I want to tell you that salesforce does not support avg function in SOQL query for date Field Types in Aggregate Functions
But still you want to find the solution then check below code
Thank you very much, guys! I understood that I can't apply the aggregate function to the Date type. But I still can't find an average date )
Malika, your code counts some average Double. Unfortunately, it's not what I need.