quarter

Returns the quarter that a given date string, s falls in.

Syntax

R = quarter(s)

R = quarter(s, quarterstart)

Inputs

s
A string representing a date in the format dd-mmm-yyyy.
Type: string
quarterstart
An optional argument that specifies the month in which the first quarter of a year begins. By default, the value for month is 1 (January).
Type: integer

Outputs

R
Number which represents the quarter that the given date, s, is in.
Type: integer

Examples:

Return quarter from a date string with default quarter start:
R = quarter('10-Jun-2019')

R = 5
Return quarter from a date string, with quarter start month specified:
R = quarter('10-Dec-2019', 7)

R = 2

Version History

2022.3