How to get maximum date from an aggregate?


I've a case where I'm having trouble to retrieve value lattest datetime from my aggregate, i try to use max function, but it only for decimal.

btw my aggregate is from local entity (I sync the entity from server to local)

anyone have some solution ?


Try one of this:

1. create an aggregate and sort by date. Then read the aggregate for the first record.

2. use advanced query.



1. how to read aggregate for the first record ?

2. advanced query not available for client action. the widget for SQL is not available like in server action


1. do loop and exit for the first read.


There's a simpler way IMO.  Create an aggregate and sort DESCENDING by the date field.  Set maxrecords to 1.  This will return the record with the highest date.  Note that if you have multiple records with the same date there is no guarantee which one you'll get unless you add other selection criteria.

Hope this helps,

tq Tan and Curt for the solution :)