convert_date {datetimeutils}R Documentation

Convert Various Formats to Date

Description

Convert dates in external formats (e.g. from MATLAB) to Date or POSIXct.

Usage

convert_date(x, type, fraction = FALSE, tz = "")

Arguments

x

numeric

type

character: "excel", "excel1904", "matlab" and "spss"/"pspp" are supported.

fraction

logical: should fractional dates (i.e. times) be used? Default is FALSE.

tz

character: if fraction is TRUE, then what time zone is to be assumed? Default is "", i.e. the local time zone.

Details

Convert the numeric representation of a date to class Date. Note that different versions of Excel use different origins: 1900-01-01 or 1904-01-01. For the latter, set type to "excel1904". For the former, convert_date uses 1899-12-31 because Excel considers 1900 a leap year (which it is not). So dates before 1 March 1900 are probably wrong (off by one day).

Value

A vector of class Date, or POSIXct if fraction is TRUE.

Author(s)

Enrico Schumann; type spss/pspp suggested and based on a patch by J\"org Beyer

See Also

as.Date, as.POSIXlt

Examples

convert_date(40000, "excel")

[Package datetimeutils version 0.6-4 Index]