I am using the lubridate
package and applying the month
function to extract month from date. I ran the str command on date field and I got
you can convert it into date format by-
new_date<- as.Date(old_date, "%m/%d/%Y")}
from new_date
, you can get the month by strftime()
month<- strftime(new_date, "%m")
old_date<- "01/01/1979"
new_date<- as.Date(old_date, "%m/%d/%Y")
new_date
#[1] "1979-01-01"
month<- strftime(new_date,"%m")
month
#[1] "01"
year<- strftime(new_date, "%Y")
year
#[1] "1979"