I have a simple date declared using following way.
private date startOfTheWeek.
But when I try to print it out it also prints the time as 00:00:00. If the problem is only printing then I can work it around with format(). But the real problem is I have to use this value in SOQL to compare against a date field. Due to this problem the records are not getting matched even if they belong to the same date. Could someone please help?
If I issue a SOQL query that includes aggregate functions, I get back a list of AggregateResult objects. From each of those, I can use ar.get('fieldname') to get the various values. But that assumes I know the names of the field. If I do a Dynamic SOQL query from a VF page controller, where the query is based on input from the user, I may not know the field names ahead of time. How can I determine the fieldnames to use when I want to access the contents of an AggregateResult object?
Having read that an AggregateResult is a special type of SObject, I tried using Dynamic Apex to discover the fields:
List<AggregateResult> lst = database.query('select count(id), grp__c from myobj__c group by grp__c'); Schema.SObjectType sot = lst.getSObjectType(); Schema.DescribeSObjectResult res = sot.getDescribe(); Set<String> setFields = res.fields.getMap().keyset(); System.debug('Fields are: ' + setFields);
But the only field I get back is "id."
Thanks for your help!