Handle multiple datetime formats representation using lubridate

r

Handling Heterogeneous datetime formats

We`ll be using parse_date_time function of lubridate package.
Multple datetime formats can be passed under orders attribute of the above function as shown below -

library(lubridate)
dates <- c( "1/22/2020 17:00", "2020-02-02 09:43:01", "2/1/2020 11:53")
parse_date_time(dates, orders = c('%Y-%m-%d %H:%M;%S','%m/%d/%Y %H:%M', '%m/%d/%y %H:%M'))

Output -

## [1] "2020-01-22 17:00:00 UTC" "2020-02-02 09:43:01 UTC"
## [3] "2020-02-01 11:53:00 UTC"

Related Posts

Download Data from a github folder using httr package in R

April 24, 2020

Read More
List, Create and Move Folder within Azure Datalake Store Gen1 using R and Rest API

September 15, 2019

Read More
Read and Write Excel from Azure Datalake Store using R and Rest API

September 6, 2019

Read More