这个问题有很多答案,但是我似乎找不到解决问题的方法。 我已将2009年3月4日至2019年4月4日的GOOGLE每日库存数据复制到Excel中。日期字符不仅具有格式,而且具有多种格式。我无法将其转换为正确的格式。
有人可以提供正确的代码吗?
This is the site from where I have copied
我知道会有更简单的方法,但是只是想了解如何做到这一点,所以我在问这个问题。
这是代码:
> google <- read_excel("Mappe1.xlsx")
> head(google)
# A tibble: 6 x 6
DATE OPEN `CLOSING PRICE` `DAILY HIGH` `DAILY LOW` `VOLUME (PCS.)`
<chr> <chr> <chr> <chr> <chr> <chr>
1 43528 1,208.28 1,205.92 1,216.30 1,201.00 406.91800000000001
2 43500 1,195.32 1,200.49 1,201.17 1,185.82 273.697
3 43469 1,182.00 1,194.43 1,196.49 1,182.00 428.96100000000001
4 3/29/2019 1,174.90 1,173.31 1,178.42 1,163.00 536.81899999999996
5 3/28/2019 1,168.72 1,168.49 1,171.55 1,159.70 348.24299999999999
6 3/27/2019 1,185.50 1,173.02 1,187.10 1,159.37 489.28500000000003
答案 0 :(得分:0)
Copy it from the main website and while pasting into excel do the above two steps, you will get proper date format according to your system format. Hope this is in order to clear your doubt.
Below formula also can be used(can be seen in option 2 image) to bring down the proper date format as per the data given by you.
=IF(ISTEXT(A3),DATE(RIGHT(A3,4),TEXT(LEFT(A3,FIND("/",A3)-1),"MM"),MID(A3,FIND("/",A3)+1,FIND("/",A3,FIND("/",A3)+1)-FIND("/",A3)-1)),DATE(TEXT(A3,"YYYY"),TEXT(A3,"MM"),TEXT(A3,"DD")))