Learn R Programming

tind (version 0.2.4)

date2num: Conversion between Dates and Their Integer Representations

Description

date2num and num2date support conversion between tind dates and integer representations of dates (days since ...) found in different software packages.

Usage

date2num(x, format)

num2date(x, format)

Value

date2num returns an integer vector and num2date returns tind representing dates.

Arguments

x

a tind with dates or an integer vector.

format

a character value determing numeric representation of date; currently, the following are supproted: "R", "MATLAB", "Excel", "SAS", "JDN" (Julian Day Number).

See Also

jdn for description of Julian Day Numbers.

Examples

Run this code
(td <- today())
fmts <- c("R", "MATLAB", "Excel", "SAS", "JDN")
(n <- sapply(fmts, function(fmt) date2num(td, fmt)))
lapply(fmts, function(fmt) num2date(n[fmt], fmt))

Run the code above in your browser using DataLab