Hi, Try either of these: DOB1<-"08/22/1976" as.numeric(format(as.Date(Sys.time()),format="%Y"))-as.numeric(format(as.Date(DOB1,format="%m/%d/%Y"),format="%Y")) #[1] 36
library(zoo) as.numeric(gsub(".*\\s","",as.yearmon(Sys.time())))-as.numeric(gsub(".*\\s","",as.yearmon(DOB1,format="%m/%d/%Y"))) #[1] 36 library(lubridate) as.period(Sys.time()-mdy(DOB1),units="year") # 1 parsed with %m/%d/%Y #estimate only: convert difftimes to intervals for accuracy #[1] "36y 0m 48d 1H 49M 26.6576771736145S" A.K. ----- Original Message ----- From: farnoosh sheikhi <farnoosh...@yahoo.com> To: "r-help@R-project.org" <r-help@r-project.org> Cc: Sent: Monday, October 8, 2012 2:26 PM Subject: [R] converting DOB format to age Hi, I have a column of DOB in mm/dd/yyyy. I want to convert this format to age. Thanks a lot. Best,Farnoosh Sheikhi [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.