0

When reading column of date and time format of excel file, the following problem occurs.

Any help would be greatly appreciated.

test <- read_excel('test.xlsx')

Data to read

2017-03-03

2017-03-04

2017-03-05

2017-03-06

2017-03-07

2017-03-08

2017-03-09

2017-03-10

1010-01-01

After Loading R

test

A tibble: 9 x 1

test1

1 42797
2 42798
3 42799
4 42800
5 42801
6 42802
7 42803
8 42804
9 1010-01-01

JAIL
  • 35
  • 2
  • Check out this post: https://stackoverflow.com/questions/43230470/how-to-convert-excel-date-format-to-proper-date-in-r – Matt Jun 07 '20 at 13:16
  • 1
    Does this answer your question? [How to convert Excel date format to proper date in R](https://stackoverflow.com/questions/43230470/how-to-convert-excel-date-format-to-proper-date-in-r) – MSR Jun 07 '20 at 13:29

1 Answers1

1

Try defining the column type in the function call:

read_excel("test.xlsx", col_types = "date")

It looks like some cells are formatted as date in excel and others probably as character. If you fix that column in Excel by setting the correct format for it, it should fix it too.

EDIT: There was a screenschot in the questions that hinted that the data wasn't in the same format in all cells (content was aligned differently). It is now deleted.

ek-g
  • 611
  • 1
  • 7