0

From R I read data into a MySQL database. There is a date column. The problem is the result is very very bad.

head(inputd$Semaine_lundi, n=20) [1] "-1-12-09 00:13:36 LMT" "-1-12-16 00:13:36 LMT" "-1-12-16 00:13:36 LMT" "-1-12-23 00:13:36 LMT" [5] "-1-12-30 00:13:36 LMT" "-1-12-06 00:13:36 LMT" "-1-12-13 00:13:36 LMT" "-1-12-20 00:13:36 LMT" [9] "-1-12-27 00:13:36 LMT" "-1-12-30 00:13:36 LMT" "-1-12-30 00:13:36 LMT" "-1-12-30 00:13:36 LMT" [13] "-1-12-30 00:13:36 LMT" "-1-12-30 00:13:36 LMT" "-1-12-30 00:13:36 LMT" "-1-12-07 00:13:36 LMT" [17] "-1-12-07 00:13:36 LMT" "-1-12-07 00:13:36 LMT" "-1-12-07 00:13:36 LMT" "-1-12-07 00:13:36 LMT"

I have never seen this before and no conversion method such as as.Date or as.POSIXct worked. How to solve it please ?

Mael Fosso
  • 360
  • 6
  • 14

1 Answers1

0

We can also use lubridate package

library(lubridate)
dmy_hms(x)
#[1] "2009-12-01 00:13:36 UTC"

data

x <- "-1-12-09 00:13:36 LMT"
akrun
  • 874,273
  • 37
  • 540
  • 662
  • Sorry but it's not working. In MySQL, the date is for example **2012-01-09 00:00:00** and when I read data, in R is become **-1-12-09 00:13:36 LMT**. So the hour has changed and the date format too. As output, I have **2009-12-01 00:13:36 WAT**. Even when I change the format parameters, the result it's wrong – Mael Fosso Dec 15 '16 at 10:35
  • @MaelElvisFosso Please check the str(yourdata) and also post the dput output of a small example – akrun Dec 15 '16 at 12:23