Reputation: 6969
sampleDate <- "08/15/2015 00:00"
sampleDateObject <- strptime(sampleDate, "%m/%d/%Y %H:%M")
Now how to get day, year, month etc. from this sampleDateObject?
Upvotes: 1
Views: 48
Reputation: 2142
sampleDateObject[['year']]
will return 115, which is the number of years after 1900. Details available with ?POSIXlt
.
Upvotes: 1
Reputation: 6969
OK, I found the answer.
sampleDateObject$mon # to access month from 0-11
To access other attributes, check this page https://stat.ethz.ch/R-manual/R-devel/library/base/html/DateTimeClasses.html
Upvotes: 0