Getting NA values while converting a variable into Date and Time format



I am currently solving the one-time series question of Analytics Vidhya hackathon in which there are two variable one is Datetime and other is count.I am currently trying to convert the Datetime variable into date format by which R can understand it but I am getting NA.

mvt = read.csv("train_unicorn.csv", stringsAsFactors=FALSE)
 mvt$Datetime = strptime(mvt$Datetime, format="%d-%m-%y %H:%M")
'data.frame':	18288 obs. of  2 variables:
 $ Datetime: POSIXlt, format: NA NA ...
 $ Count   : int  8 2 6 2 2 2 2 2 6 2 ...


@Harry: Please try with below code:

train$Datetime = as.POSIXct(train$Datetime,format="%d-%m-%Y %H:%M")


Hi @harry

the mistake is %Y not %y

traindata$Datetime <-strptime(traindata$Datetime, “%d-%m-%Y %H:%M”)

Have fun