Skip to content

Date vs DateTime when the time is 0:00:00 #314

@hurak

Description

@hurak

This is clearly a duplicate of #237, which stalled, and that is why I open it as a new issue. Perhaps the two can then merge or just be closed together or whatever.

I created a very minimal Excel file (download here), see the screenshot
Image

When importing this as a table using the code

julia> using XLSX

julia> xt = XLSX.readtable("bug_report_mwe.xlsx", "List1")
XLSX.DataTable(Any[Any[Date("2020-10-22"), DateTime("2020-10-22T00:10:00")], Any[10, 20]], [:DateTime, :Value], Dict(:Value => 2, :DateTime => 1))

the type of the first date-and-time cell entry is just Date, while that of the second is DateTime. The following code shows this explicitly

julia> xt.data
2-element Vector{Any}:
 Any[Date("2020-10-22"), DateTime("2020-10-22T00:10:00")]
 Any[10, 20]

This creates problems when working with date-and-timed data sets (typically with DataFrames.jl or TSFrames.jl) as the type of the elements in the first (the index) column is not a subset of the abstract TimeType. Clearly, even 0:00:00 should be recognised as a valid time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions