You need to sign in to do that
Don't have an account?
bohemianguy100
Date comparision: find the most recent date
I'm trying to compare dates to determine the most recent date out of several records. I was to get the record with the most recent date below, but that doesn't appear to be working.
tmpPostedDate = null postedDate = null; for (Sales_Invoice__c s : salesInvoiceList) { tmpPostedDate = s.Posting_Date__c; if (tmpPostedDate > postedDate) { postedDate = tmpPostedDate; } else { s.Posting_Date__c; } }
Is there another way to get the most recent date when comparing across several records?
Thanks.
I stole this from another post, but it should work... Since SOQL doesn't have a MAX() function, you have to sort on date, and limit returns to 1.
If you want to read the post on this subject, it's located here:
Order By Date discussion