Skip to content
Back to formatted view

Raw Message

Message-ID: <SA1PR13MB4878B99FF67737AB8EC3B411C3E39@SA1PR13MB4878.namprd13.prod.outlook.com>
Date: 2021-07-21T19:23:28Z
From: Shawn Way
Subject: Help with Converting Excel Times to R

I've usually had good luck with this, but something is not working well.  I have two datetimes in excel

7/20/21 13:30
7/20/21 13:40

And when I convert these to excel's normal storage schema, I get the following:

42935.5625
42935.56944

Just try to convert this to a POSIX class gives me issues.

> dt <- c(42935.5625,42935.5694444444)

> as.POSIXct(dt,origin="1899-12-30 00:00:00",tz="GMT")

[1] "1899-12-30 11:55:36 GMT" "1899-12-30 11:55:36 GMT"

As you can see, there is a world of difference here.  I've tried any number of solutions such as lubridate, etc and I get the same result

> as_datetime(dt,origin="1899-12-30 00:00:00")

[1] "1899-12-30 11:55:36 UTC" "1899-12-30 11:55:36 UTC"

Any ideas about what I'm doing wrong?


Shawn Way