cleanDate: Clean dates

View source: R/date_format.R

cleanDateR Documentation

Clean dates

Description

Clean a date and reformat it to another style.

Usage

cleanDate(
  x,
  original.format,
  preferred.format,
  existing.missing.codes = "",
  return.missing.code = NA,
  sep = "/"
)

Arguments

x

a date string or a numeric representation of a date (e.g. January 13th, 1991 would be 19910113)

original.format

format of input x

preferred.format

format to change x to

existing.missing.codes

missing dates

return.missing.code

what to return if there is a missing input

sep

date separator. Defaults to "/"

Value

A date string cleaned and formatted from the original (unformatted) date

Author(s)

Samuel Leung, Derek Chiu

See Also

Other date formatting functions: chr_to_date(), formatDate(), getFormat(), numericToDate()

Examples

cleanDate("09/11/1991", original.format = "MM.DD.YYYY", preferred.format = "DD.MM.YYYY")
cleanDate(11091991, original.format = "DD.MM.YYYY", preferred.format = "YYYY.MMM.DD")
cleanDate(11091991, original.format = "DD.MM.YYYY", preferred.format = "YYYY.MMM.DD", sep = "-")

TalhoukLab/biostatUtil documentation built on April 14, 2025, 4:15 a.m.