fifthace fifthace - 1 year ago 79
R Question

Using as.POSIXct in R giving na for identical character structures

I have two timestamps in character form that I want to convert to a POSIX format in R.


1: "2013-03-30 17:45:00"

2: "2013-03-31 02:05:00"

The first one converts fine, the second one gives me
. The
are downloaded as
from an
SQL server
. Anyone have any ideas what is going wrong?

I don't have the reputation to attach a screenshot, so a screenshot of my R console showing the result is provided here:

Answer Source

It looks like a DST issue. I assume from your name you are from Sweden or thereabouts. There was no time in Sweden between 2am and 3am on the 31st March 2013, as the clocks went forward then.

as.POSIXct("2013-03-31 02:05:00",format="%Y-%m-%d %H:%M:%S", tz="Europe/Stockholm")
[1] NA

This is true for anyone on Central European Time (CET).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download