Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

quarter

Returns the quarter of given date

Syntax

q = quarter(date)
q = quarter(___,month1)
q = quarter(date,month1,dateformat)

Description

example

q = quarter(date) returns the quarter of the given date, assuming the standard calendar (starting on January 1st).

example

q = quarter(___,month1) returns the quarter of the date for a calendar which starts on the month specified by month1. month1 must be an integer between 112 representing Jan-Dec respectively.

example

q = quarter(date,month1,dateformat) returns the quarter of the date for a calendar which starts on the month specified by month1. month1 must be an integer between 112 representing January to December respectively. The dateformat input is a character vector to specify the format of your date character vector in case it is not normally recognized by the datenum function.

Examples

collapse all

quarter returns the quarter of the given date, assuming the standard calendar that starts on Jan 1st.

quarter('7-Apr-2013')
ans = 2

quarter returns the quarter of the date for a calendar which starts on the month specified by month1.

quarter('7-Apr-2013',5)
ans = 4

If the financial calendar starts in May (where month1 = 5), April would be the last month and fall in the last quarter.

When using quarter, the optional input argument for dateformat is a character vector which lets you specify the format of your date character vector in case it isn't normally recognized by the datenum function.

quarter('07-04-2013',1)
ans = 3

This gives the quarter 3 because by default datenum interprets the date as July 7th, 2013.

If you really meant April 7th, 2013, you can use dateformat to specify the intended format.

quarter('07-04-2013',1,'dd-mm-yyyy')
ans = 2

Input Arguments

collapse all

Date in a quarter, specified as serial date numbers or date character vectors.

Data Types: double | char

First month in a calendar, specified as an integer with a value between 112, representing January to December respectively. Use month1 when the standard calendar that starts on January 1st does not apply.

Data Types: double

Format of date, specified as a character vector. dateformat input is a character vector to specify the format of your date character vector in case it is not normally recognized by the datenum function.

Data Types: char

Output Arguments

collapse all

Quarter for given date, returned as an integer between 14.

See Also

Introduced in R2016a

Was this topic helpful?