You need to sign in to do that
Don't have an account?
Arun B
Max(Date Column) : is it possible in SOQL
Hello there,
I wanted to find out the max(of a list of Dates) .e.g: Select PSOD_Project__r.Name,Resource__r.Name,max(Period_Beginning__c) from Time_Sheet__c where PSOD_Project__r.Name = 'PSOD Internal'
This is not working; Any hints whether this is feasible at all in SOQL ? if so, help pls.
Thanks,
Arun B
I wanted to find out the max(of a list of Dates) .e.g: Select PSOD_Project__r.Name,Resource__r.Name,max(Period_Beginning__c) from Time_Sheet__c where PSOD_Project__r.Name = 'PSOD Internal'
This is not working; Any hints whether this is feasible at all in SOQL ? if so, help pls.
Thanks,
Arun B
Thanks,
Arun B
Regards,
Arun B
I had the same challenge and most searches about it let to this post so I thought I'd post the solution here. My problem was to select from the latest ActivityDate on Tasks or Activities and update on the related Contact (person account).
Here's what I did to get around all limitations:
- Create a custom Last Activity Time string field on the Activity record
- Since you can't access the ActivityDate field in formulas, update the above field using before triggers on both Task and Event with the long values of the field
and similarly for Task:
Now that we have the latest time on the fields, have similar triggers on both Event and Task to get the maximum of the fields and update accordingly.
....and the same thing for Task and you're done!
hope this helps!
-Manu
I am actually trying to do the same thing but just a simple correctionMAX() in SOQL is there, it works just fine for numeric values, but it seems to have problems with date fields.
You can look at all available aggregate functions here: Agregate Functions Docs
This works with dates using aggregate functions.
Select MAX(createddate) From Opportunity
Depending on your verion of the IDE it may not show a result, but executing in the Developer console will render a result.
Fahd
cloudras.com
Select createdDate from opportunity order by createdDate desc limit 1
this will give us the opportunity with the latest create date. Wouldn't it?
Do i need to use aggregagte function?