`max` and `min` of single dates

I want aggregate dates and find the most recent date in a bunch of dates. For example I want to know the age of the youngest kid in a family. To do this I have to find the max of several dates. If there are a least two kids everything is fine:

julia> max(Date("2013-07-31"), Date("2017-07-20"))
2017-07-20

However, some families have just one kid:

julia> max(Date("2013-07-31"))
ERROR: MethodError: no method matching max(::Date)
Closest candidates are:
  max(::Any, ::Missing) at missing.jl:104
  max(::Any, ::Any) at operators.jl:408
  max(::Any, ::Any, ::Any, ::Any...) at operators.jl:529
  ...
Stacktrace:
 [1] top-level scope at REPL[3]:1

For Real something like this works fine:

julia> max(1.3)
1.3

I would like to see this behavior also for dates and times.

Seems like an oversight. Would you mind opening an issue (or even marking a PR!)?

2 Likes

Will do -

2 Likes

Done: Add methods min, max, minmax taking only single Dates.AbstractTime by pfarndt · Pull Request #32525 · JuliaLang/julia · GitHub

4 Likes