Skip to content

MIN and MAX throw on lists of dates, but work on numbers #245

Description

@cesarParra

MIN and MAX work on numbers but throw a runtime error on dates.

Repro

expression.Evaluator.run('MIN([3, 1, 2])', someId);                              // => 1
expression.Evaluator.run('MIN([DATE(2026,1,1), DATE(2026,2,1)])', someId);       // runtime error
expression.Evaluator.run('MAX([DATE(2026,1,1), DATE(2026,2,1)])', someId);       // runtime error

Expected: the earliest / latest date.
Actual: a runtime error with an empty message.

Why it matters

"Earliest" and "latest" over a set of child records is one of the most common things a document or
formula wants to say — first activity, last payment, next due date:

Tasks -> MAP(ActivityDate)   then the earliest of those

The workaround is -> SORT(ActivityDate) -> MAP(ActivityDate) -> FIRST(), which works but is
obscure, and SORT + FIRST are doing a job MIN already names.

Environment

Expression 1.52.0.1, Developer Edition scratch org.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions