I want to convert Birth.Date column into a format as.Date
$ Birth.Date : num 38525 39425 39679 39675 39740
I want to convert Birth.Date column into a format as.Date
$ Birth.Date : num 38525 39425 39679 39675 39740
This looks like an Excel
date.
If this is the case, use as.Date
with origin = "1899-12-30"
:
as.Date(c(38525,39425, 39679, 39675, 39740), origin = "1899-12-30")
#"2005-06-22" "2007-12-09" "2008-08-19" "2008-08-15" "2008-10-19"
We could use excel_numeric_to_date
from janitor
package
library(tibble)
library(janitor)
# vector with your values
date_vector <- c(38525, 39425, 39679, 39675, 39740, 38525, 39425, 39679, 39675, 39740)
# transform to date
excel_numeric_to_date(as.numeric(as.character(date_vector)), date_system = "modern")
Output:
[1] "2005-06-22" "2007-12-09" "2008-08-19" "2008-08-15" "2008-10-19" "2005-06-22" "2007-12-09" "2008-08-19" "2008-08-15"
[10] "2008-10-19"