Skip to content

Average of Dates #54542

Open
Open
@alaindebecker

Description

@alaindebecker

That you cannot add Dates and cannot divide a Dates by an integer seams perfectly normal.
However computing the mean of Dates is well founded and sometimes mostly needed.

Example:

using Statistics, Dates

mean([Date("2024-05-22"), Date("2024-05-20")])
### ERROR: MethodError: no method matching /(::Date, ::Int64)

sum([Date("2024-05-22"), Date("2024-05-20")])  ÷ 2
### ERROR: MethodError: no method matching +(::Date, ::Date)

mean([DateTime("2024-05-22"), DateTime("2024-05-20")])
ERROR: MethodError: no method matching /(::DateTime, ::Int64)

versioninfo()
#==
Julia Version 1.10.2
Commit bd47eca2c8 (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 12 × Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)
==#```

Metadata

Metadata

Assignees

No one assigned

    Labels

    datesDates, times, and the Dates stdlib module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions