R rounds time to date

84 views Asked by At

By loading a table of PostgreSQL (RPostgreSQL) time rounds to date. Instead, "2015-01-28 03:04:01 CET" have "2015-01-28 CET", but it is the class "POSIXct" "POSIXt", not only shows, but actually "2015-01-28 00:00:00 CET". And it is only on the local mac, R in server receives the same table without problems. Rather, any options. Can anyone help?

> command3 <- "SELECT requested_at FROM rides  WHERE  city_id != 1;"
> riders3 <- dbSendQuery(con, command3)
> riders_total <- fetch(riders3, n = -1)
> riders_total$requested_at[1]
[1] "2015-04-19 CEST"     #####    is "2015-04-19 03:04:31 CEST" !
> riders_total$requested_at[1] + 1
[1] "2015-04-19 00:00:01 CEST"
> dput(head(riders_total, 10))
structure(list(requested_at = structure(c(1429394400, 1429653600, 
1429653600, 1431468000, 1431468000, 1429394400, 1431468000, 1417993200, 
1430085600, 1431468000), class = c("POSIXct", "POSIXt"), tzone = "")), .Names = "requested_at", row.names = c(NA, 
10L), class = "data.frame")
1

There are 1 answers

0
Batanichek On

Had simular problem with Date on different PC got different value. Find only one way to resolve( simplist way without changing PC options) : using to_char in select and then as.POSIXct in R