DescTools (version 0.99.14)

XLDateToPOSIXct: Convert Excel Dates to POSIXct

Description

As I repeatedly forgot how to convert Excel dates to POSIX here's the specific function.

Usage

XLDateToPOSIXct(x, tz = "GMT")

Arguments

x
the integer vector to be converted.
tz
a time zone specification to be used for the conversion, if one is required. See as.POSIXct.

Value

  • return an object of the class POSIXct. Date-times known to be invalid will be returned as NA.

Details

XLGetRange will return dates as integer values, because XL stores them as integers. An Excel date can be converted with the (unusual) origin of as.Date(myDate, origin="1899-12-30"), which is implemented here.

See Also

as.POSIXct

Examples

Run this code
XLDateToPOSIXct(41025)
XLDateToPOSIXct(c(41025.23, 41035.52))

Run the code above in your browser using DataCamp Workspace