GenEst (version 1.2.4)

checkDate: Checks whether a vector of data can be interpreted as dates

Description

Checks whether the dates are in a standard format and sensible. If so, function returns the dates converted to ISO 8601 yyyy-mm-dd format. Acceptable formats are yyyy-mm-dd, yyyy/mm/dd, mm/dd/yyyy, and dd/mm/yyyy. If format is mm/dd/yyyy or dd/mm/yyyy, the dates must be interpretable unambiguously. Also, dates must be later than 1900-01-01. This additional check provides some protection against common data entry errors like entering a year as 0217 or 1017 instead of 2017.

Usage

checkDate(testdate)

Arguments

testdate

Date(s) to check and format.

Value

dates formatted as yyyy-mm-dd (if possible) or NULL (if some value is not interpretable as a date after 1900-01-01).

Examples

Run this code
# NOT RUN {
 checkDate("02/20/2018")
 checkDate("10/08/2018")

# }

Run the code above in your browser using DataCamp Workspace