Learn R Programming

Biograph (version 2.0.6)

date_convert: Converts vector of dates from one format to another

Description

Converts dates at transition to dates in another format or to ages

Usage

date_convert(d,format.in,selectday,format.out,born,format.born)

Arguments

d
A vector of dates to be converted
format.in
Format of input date
selectday
If input date is in CMC, selectday gives the day of the month. Default is 1
format.out
Format of output date
born
Date of birth for computation of age. Format the date of birth is format.in. May be omitted, unless date at transition need to be converted to age
format.born
Format of date of birth

Value

date
Dates at transition. Object of class 'Date'(number of days since 1970-01-01)
datep
Dates for printing

Examples

Run this code
    data(GLHS)
    b <- date_convert(d='01/01/2011',format.in='%m/%d/%Y',selectday=1,format.out='day-month-year')  
    dd <- GLHS$marriage
    fo <- 'day-mon-year'
    gb <- GLHS$born
    bb<- date_convert(d=dd,format.in="CMC",selectday=1,format.out=fo,born=gb,format.born="CMC")
    

Run the code above in your browser using DataLab