How can I retrive the time only with xlconnect?

烂漫一生 提交于 2019-12-06 19:36:34
Martin Studer

XLConnect uses POSIXct to represent date-time values in a data.frame. If you only want to extract the time component you may use strftime(your_column, format = "%H:%M:%S") (representation as character).

Some background as to why you get 1899-12-31: Excel stores date-time values as decimal numbers representing the number of days since 1900-01-00 (yes, day 00! - which doesn't exist). Fractional days represent hours, minutes and seconds. As such the decimal number 1.0 represents 1900-01-01 and the number 0.0 represents 1900-01-00. Since the latter doesn't exist, in XLConnect it's actually represented as the day before day 1 which is 1899-12-31. Time-only values are represented as decimal numbers 0.xxx in Excel. In accordance with the above, when imported in XLConnect this results in 1899-12-31 HH:MM:SS.

Additional information on Excel date-time values can be found here.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!