Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

quarter

Get the fiscal quarter and semester of a date-time


Description

Quarters divide the year into fourths. Semesters divide the year into halfs.

Usage

quarter(x, with_year = FALSE, fiscal_start = 1)

semester(x, with_year = FALSE)

Arguments

x

a date-time object of class POSIXct, POSIXlt, Date, chron, yearmon, yearqtr, zoo, zooreg, timeDate, xts, its, ti, jul, timeSeries, fts or anything else that can be converted with as.POSIXlt

with_year

logical indicating whether or not to include the quarter's year.

fiscal_start

numeric indicating the starting month of a fiscal year

Value

numeric

Examples

x <- ymd(c("2012-03-26", "2012-05-04", "2012-09-23", "2012-12-31"))
quarter(x)
quarter(x, with_year = TRUE)
quarter(x, with_year = TRUE, fiscal_start = 11)
semester(x)
semester(x, with_year = TRUE)

lubridate

Make Dealing with Dates a Little Easier

v1.7.10
GPL (>= 2)
Authors
Vitalie Spinu [aut, cre], Garrett Grolemund [aut], Hadley Wickham [aut], Ian Lyttle [ctb], Imanuel Costigan [ctb], Jason Law [ctb], Doug Mitarotonda [ctb], Joseph Larmarange [ctb], Jonathan Boiser [ctb], Chel Hee Lee [ctb], Google Inc. [ctb, cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.