Hello,
as.Date() outputs an object of class "Date", you want an object of
class
c("POSIXt", "POSIXct"). Use as.POSIXct().
Hope this helps,
Rui Barradas
?s 16:04 de 08/05/19, reichmanj at sbcglobal.net
escreveu:> r-Help Community
>
>
>
> I need to convert a date-time field (column) but I'm losing the time
when
> I convert using ..
>
>
>
> tsData <- myData[,10, drop=FALSE]
>
> tsData$date_time <- as.Date(tsData$date_time, format="%m/%d/%y
%H:%M")
>
> head(tsData)
>
>
>
>
>
>
>
>
> date_time
>
> <date>
>
>
>
> 1
>
> 2013-06-20
>
>
>
> 2
>
> 2013-06-20
>
>
>
> 3
>
> 2013-06-20
>
>
>
> 4
>
> 2013-06-20
>
>
>
> 5
>
> 2013-05-30
>
>
>
> 6
>
> 2013-06-20
>
>
>
>
>
> R is doing what I'm asing it to do so I'm obviously using the wrong
command.
> How do I convert, retaining the time
>
>
>
> Sincerely
>
>
>
> Jeffery (Jeff) Reichman
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>