computeCtime_days: Calculates the difference of time between two dates in days

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/xpssComputeDates.R

Description

R Implementation of the SPSS CTIME.DAYS Function. computeCtime_days is a helper function for xpssCompute.

Usage

1

Arguments

x

atomic object of class character, POSIXlt or POSIXt holding date data

date

atomic object of class character, POSIXlt or POSIXt holding date data

Details

The input format of the date's is "YYYY-MM-DD" as Date, and with timeparameters YYYY-MM-DD HH:MM:SS.

Examples:

Date w/o Time Date with Time
YYYY-MM-DD YYYY-MM-DD HH:MM:SS
2015-01-01 2015-01-01 00:00:00
2015-12-31 2015-12-31 23:59:59

It is possible to calculate the difference between the dates, even if they do not have the same structure. It is possible to match dates without time paramters, with dates which contain the time parameters. Additionally it is possible to match dates which are not in the right format.

Note: The calculation of two dates, one with the format YYYY-MM-DD and the other one with the format DD-MM-YYYY is valid, but not recommended.

Value

computeCtime_days returns the difference between x and date in days.

Author(s)

Bastian Wiessner

See Also

difftime DateTimeClasses as.POSIXlt strptime

Examples

1
2
xpssCompute(x="2013-09-14", fun="computeCtime_days", date="2013-09-11")
xpssCompute(x="2015-11-28", fun="computeCtime_days", date="2014-11-28")

translateSPSS2R documentation built on May 30, 2017, 4:31 a.m.