formatDate: Format Dates

Description Usage Arguments Details Author(s) See Also Examples

View source: R/formatDate.R

Description

formatDate converts characters or numbers to dates. is.Date indicates which elements are Dates.

Usage

1
2
3
formatDate(x, format = "dmY", sep = "/", century = NULL)

is.Date(x)

Arguments

x

a character or numeric object

format

only for character vectors:

sep

separator character for date components

century

specify either 2000 or 1900 for two-digit years

Details

"dmY" represents dd mm YYYY format. In combination with separators from sep, this can change to several date formats. For example, "dmy" + "-" convert to "dd-mm-YYYY" format.

See as.Date for more date formats.

Author(s)

Myo Minn Oo (Email: dr.myominnoo@gmail.com | Website: https://myominnoo.github.io/)

See Also

generate, egen, labelVars

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
dates <- c("2019-01-15", "2019-01-20", "2019-01-21", "2019-01-22")
is.Date(dates)
formatDate(dates, "Ymd", "-")
y <- formatDate(dates, "Ymd", "-")
is.Date(y)
y
# dates in numeric format MS excel
x <- 42705:42710
y <- formatDate(x)
y

myominnoo/mStats_beta documentation built on Feb. 29, 2020, 8:17 a.m.