Skip to content
Prev 388576 / 398530 Next

Help with Converting Excel Times to R

Hello,
1904 Date System, which isn't a problem, it just means that your numbers
are days from 1904-01-01 instead of 1900-01-01.
The following is my solution:

times <- c(42935.5625,42935.5694444444)
as.POSIXlt((


    # offset the days by the origin for Excel
    times + unclass(as.Date("1904-01-01"))


# multiply by 86400 to convert number of days to number of seconds
) * 86400,


# .Date(0) is the origin day for R
origin = .Date(0), tz = "GMT")

though a better way to do it would be to save the datetimes in Excel as
text, and then use `as.POSIXct(..., format = ...)` on the text field once
read into R. Something like:


times <- c("7/20/2021 13:30", "7/20/2021 13:40")
as.POSIXlt(times, format = "%m/%d/%Y %H:%M", tz = "GMT")
On Wed, Jul 21, 2021 at 6:49 PM Shawn Way <sway at empowerpharmacy.com> wrote:

            

  
  
Message-ID: <CAPcHnpRcS2W8Mp51Ksd-cXXc2iX20-ob9z8QhUmKyYndrLyWZQ@mail.gmail.com>
In-Reply-To: <SA1PR13MB4878B99FF67737AB8EC3B411C3E39@SA1PR13MB4878.namprd13.prod.outlook.com>