Last chance! 50% off unlimited learning
Sale ends in
Year(x)
Quarter(x)
Month(x, format = c("num", "abbr", "full"), lang = c("local", "engl"),
stringsAsFactors = TRUE)
Week(x)
Day(x)
Weekday(x, format = c("num", "abbr", "full"), lang = c("local", "engl"),
stringsAsFactors = TRUE)
Yearday(x)
Yearmonth(x)
Day(x) <- value
IsWeekend(x)
format()
and its strange codes...
Based on the requested time component, the output is as follows:
Year returns the year of the input date in yyyy format.
Quarter returns the quarter of the year (1 to 4) for the input date.
Month returns the month of the year (1 to 12) for the input date.
Week returns the week of the year for the input date (0 to 53), as defined in ISO8601.
Weekday returns the week day of the input date. (1 - Monday, 2 - Tuesday, ... 7 - Sunday). (Names and abbreviations in the current locale!)
Yearday returns the day of the year numbering (1 to 366).
Day returns the day of the month (1 to 31).
Yearmonth returns the yearmonth representation (YYYYMM) of a date as longinteger.
IsWeekend returns TRUE, if the date x falls on a weekend.
The day can not only be extracted, but as well defined. See examples.strptime
, DateTimeClasses
, as.POSIXlt
x <- Sys.Date()
Year(x)
Quarter(x)
Month(x)
Month(x, format = "abb", lang="engl")
Month(x, format = "abb", lang="local")
Month(x, format = "full", lang="engl")
Month(x, format = "full", lang="local")
Week(x)
Day(x)
Day(x) <- 20
x
Weekday(x)
Weekday(x, format = "abb", lang="engl")
Weekday(x, format = "abb", lang="local")
Weekday(x, format = "full", lang="engl")
Weekday(x, format = "full", lang="local")
Yearday(x)
IsWeekend(x)
# let's generate a time sequence by weeks
Month(seq(from=as.Date(Sys.Date()), to=Sys.Date()+150, by="weeks"), format="a")
Run the code above in your browser using DataLab