Learn R Programming

translateSPSS2R (version 1.0.0)

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

Description

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

Usage

computeCtime_days(x,date=NULL)

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

Value

computeCtime_days returns the difference between x and date in days.

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

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.

See Also

difftime DateTimeClasses as.POSIXlt strptime

Examples

Run this code
xpssCompute(x="2013-09-14", fun="computeCtime_days", date="2013-09-11")
xpssCompute(x="2015-11-28", fun="computeCtime_days", date="2014-11-28")

Run the code above in your browser using DataLab