Slaesforce FAQ

how to get max of dates in salesforce

by Isabelle Kuphal II Published 2 years ago Updated 2 years ago
image

then suppose your list of date is 'datelist' then datelist = datelist.sort (); date minDate = datelist.get (0); date maxDate = datelist.get (datelist.size ()-1); would provide you with minimum and maximum date.

To use MAX() or MIN(), you must convert dates to an integer first. Then, use your returned value to subtract from the current date (Today). Top get the most recent date of a list, you'll need to use the MIN() function. To get the earliest date, you'll need to use the MAX() function.Jul 7, 2015

Full Answer

What is the earliest date in Salesforce that is valid?

For example, in the Pacific time zone, the earliest valid date is 1699-12-31T16:00:00, or 4:00 PM on December 31, 1699. Thanks for contributing an answer to Salesforce Stack Exchange!

Is there a simple correctionmax () in soql for date fields?

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.

Where can I find aggregate functions for dates?

You can look at all available aggregate functions here: Agregate Functions Docs  This works with dates using aggregate functions. Depending on your verion of the IDE it may not show a result, but executing in the Developer console will render a result.

Is there a soql equivalent to Max ()?

Any other approach do you suggest ? There's no SOQL equivalent to max (), so you're stuck with loading ALL relevant records and sorting it out via Apex code. Easiest would be to load in Date desc order, loop through and only pay attention when a new Resource is mentioned.

image

How do you use the max formula in Salesforce?

Using the MAX() function The MAX function is categorized as the Math function; the syntax for this formula is MAX(number,number,...). This function returns the greatest of all arguments, for example, MAX(Opportunity. Projected_Revenue__c:SUM, AMOUNT:SUM) .

How do you find the maximum date in Excel?

Max function to find latest date If you want to find out the latest dates in the range, you can enter the formula =MAX(A1:D7), and press the Enter key.

How do you find the maximum or minimum value of a certain date range?

Use the matrix function. Add a column B with the year calculated. Then in cell D2 write the following: =MAX(IF(B:B=B2,C:C)) and press CTRL + SHIFT + ENTER .

What is Xlookup used for?

The XLOOKUP function searches a range or an array, and then returns the item corresponding to the first match it finds. If no match exists, then XLOOKUP can return the closest (approximate) match.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9