I have this code, but it doesn't seem to be working.
AccountCollection accts = new AccountCollection();
PredicateExpression filter = new PredicateExpression();
filter.Add(AccountFields.ClientId == clientId);
var date = (DateTime)accts.GetScalar(AccountFieldIndex.SetupDate, null, AggregateFunction.Max, filter);
It's always returning the value of first date field.