# XLSX parsing DateTime

**URL:** https://discourse.julialang.org/t/xlsx-parsing-datetime/103071
**Category:** General Usage
**Tags:** xlsx, datetime
**Created:** [August 22, 2023, 2:57pm UTC](https://discourse.julialang.org/t/xlsx-parsing-datetime/103071 "2023-08-22T14:57:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [August 22, 2023, 2:57pm UTC](https://discourse.julialang.org/t/xlsx-parsing-datetime/103071/1 "2023-08-22T14:57:30Z")

</div>

I am loading data from an Excel file that includes DateTime data. The DateTime string, when the time is 0:00 is parsed as a Date instead of a DateTime. An example of the data being loaded is:

```julia
Date	a
2023-07-11 0:00	45.12
2023-07-11 0:01	45.14
2023-07-11 0:02	45.09
2023-07-11 0:03	44.69
2023-07-12 0:00	44.89

```

If this data is read from the Excel spreadsheet it gives the output:

```julia
julia> test = DataFrame(XLSX.readtable("test.xlsx", "Sheet1"))
5×2 DataFrame
 Row │ Date a
     │ Any Any
─────┼──────────────────────────────
   1 │ 2023-07-11 45.1199
   2 │ 2023-07-11T00:01:00 45.1426
   3 │ 2023-07-11T00:02:00 45.0878
   4 │ 2023-07-11T00:03:00 44.6917
   5 │ 2023-07-12 44.8935

```

Another command will do better in terms of typing the non Date columns as follows:

```julia
julia> test = XLSX.openxlsx("test.xlsx") do xf
           DataFrame(XLSX.gettable(xf["Sheet1"]; infer_eltypes=true))
       end
5×2 DataFrame
 Row │ Date a
     │ Any Float64
─────┼──────────────────────────────
   1 │ 2023-07-11 45.1199
   2 │ 2023-07-11T00:01:00 45.1426
   3 │ 2023-07-11T00:02:00 45.0878
   4 │ 2023-07-11T00:03:00 44.6917
   5 │ 2023-07-12 44.8935

```

I am able to get the desired DateTime type for the first column using the command

```julia
julia> test.Date = DateTime.(test.Date)
5-element Vector{DateTime}:
 2023-07-11T00:00:00
 2023-07-11T00:01:00
 2023-07-11T00:02:00
 2023-07-11T00:03:00
 2023-07-12T00:00:00

```

However I don’t think that I should need to do this. I think the default behaviour for parsing a DateTime string like “2023-07-11 0:00” should return a DateTime type rather than a Date type.

Is this a bug?

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [August 22, 2023, 3:31pm UTC](https://discourse.julialang.org/t/xlsx-parsing-datetime/103071/2 "2023-08-22T15:31:19Z")

</div>

Seems worth opening an issue on the XLSX repo.

---

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [August 22, 2023, 4:35pm UTC](https://discourse.julialang.org/t/xlsx-parsing-datetime/103071/3 "2023-08-22T16:35:38Z")

</div>

Thanks done
