quarter
Quarter of the year (1 to 4) of a datetime.
Category: Language Fundamentals > Data Types
Syntax
q = quarter(t)
Returns the quarter that each element of t falls in.
Description
Quarters follow the calendar year: January to March is 1, April to June is 2, July to September is 3 and October to December is 4. Fiscal quarters that start in other months must be computed by shifting the date first.
Input arguments
t- Datetime array.
Output arguments
q- Array of the same size as
twith values 1, 2, 3 or 4.
Example
quarter(datetime(2024, [1 4 8 12], 1))
Output
ans = 1×4
1 2 3 4