Libraries
library(lubridate) #dates conversion package
library(DT) #table package
library(rio)
install_formats()
## [1] TRUE
Import Data
data<-import("E:\\New folder\\data.xlsx")
#subset the data
date_unconverted<-data[1:3]
Structure of the Data
str(date_unconverted)
## 'data.frame': 309 obs. of 3 variables:
## $ SubmissionDate: chr "2019-08-14T13:54:13.784Z" "2019-08-14T13:51:03.457Z" "2019-08-14T13:54:04.777Z" "2019-08-14T13:50:18.188Z" ...
## $ starttime : chr "2019-08-14T10:40:57.028+03" "2019-08-14T15:07:32.591+03" "2019-08-14T09:46:59.358+03" "2019-08-14T11:42:42.228+03" ...
## $ endtime : chr "2019-08-14T16:44:14.403+03" "2019-08-14T15:28:13.059+03" "2019-08-14T16:49:21.161+03" "2019-08-14T15:06:17.162+03" ...
DT::datatable(date_unconverted,class = 'cell-border stripe',rownames = F,caption = "Table 1: Un-converted Dates",options = list(columnDefs = list(list(className = 'dt-center', targets = 0:2))))
Convert the Dates
dates<-data[1:3]
dates$SubmissionDate<-date(dates$SubmissionDate)
dates$starttime<-date(dates$starttime)
dates$endtime<-date(dates$endtime)
Converted Dates Output
datatable(dates,class = 'cell-border stripe',rownames = F,caption = "Table 2: Converted Dates",options = list(columnDefs = list(list(className = 'dt-center', targets = 0:2))))