I have multiple excel files (160) where one 'date' column about 100 observations is in not in proper format. While exporting all the files together the date column changes as follows
Date Column in Excel
| Date |
|---|
| 05-07-2015 |
| 04-07-2015 |
| 03-07-2015 |
| 02-07-2015 |
| ....... |
Date column importing in R
| Date |
|---|
| 42190 |
| 42189 |
| 42188 |
| 42187 |
| ...... |
How to change "42191" to original date format?
Excel may save dates as numeric or maybe they imported in a numeric format. So you can try:
# from Windows Excel:
as.Date(42190, origin = "1899-12-30")
[1] "2015-07-05"
# from Mac Excel:
as.Date(42190, origin = "1904-01-01")
Interestingly, Excel support page define the origin date for Windows excel as "1900-01-01", but from here and here you can see that for R, date of "1899-12-30" should use as the origin date.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With