datetime

Methods

Method Reference: datetime.quarter

datetime: Q = quarter (T)

Quarter component of a datetime array.

Q = quarter (T) returns the quarter number for each element of the input datetime array T. The output Q is a double array containing integer values in the range [1, 4] and it has the same size as T. Not-A-Time (NaT) values in T are returned as NaN in the output array.

Source Code: datetime

quarter returns the quarter of the year (1 to 4) for each element.

 t = datetime (2024, [2, 5, 8, 11], 1)
t =
  1x4 datetime array

    01-Feb-2024    01-May-2024    01-Aug-2024    01-Nov-2024
 quarter (t)
ans =

   1   2   3   4