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.

month

Syntax

  • [MonthNum,MonthString] = month(Date)
  • [MonthNum,MonthString] = month(Date,F)

Description

[MonthNum,MonthString] = month(Date) returns the month of date given a serial date number or a date character vector.

[MonthNum,MonthString] = month(Date,F) returns the month of date given a serial date number or a date character vector, Date, using format defined by the optional input F. Date can be a character array where each row corresponds to one date character vector, or a one-dimensional cell array of character vectors. All the character vectors in Date must have the same format F. F must designate a supported date format symbol. For more information on supported date formats, see datestr.

Examples

collapse all

Find the month for Date using a serial date number.

[MonthNum, MonthString] = month(730368)
MonthNum =

     9


MonthString =

Sep

Find the month for Date using a date character vector format.

[MonthNum, MonthString] = month('05-Sep-1999')
MonthNum =

     9


MonthString =

Sep

Use the optional F argument to designate a country-specific date format for a given Date.

[MonthNum, MonthString] = month('1999/05/09','yyyy/dd/mm')
MonthNum =

     9


MonthString =

Sep

Related Examples

Input Arguments

collapse all

Date to determine month, specified as a serial date number or date character vector.

Date can be an array of date character vectors, where each row corresponds to one date character vector, or a one-dimensional cell array of character vectors. All the character vectors in Date must have the same format F. F must designate a supported date format symbol. For more information on supported date formats, see datestr

Data Types: single | double | char | cell

Date format symbol, specified as a character vector to designate the date format symbol for input argument Date. For more information on supported date character vector formats, see datestr. Note, formats with 'Q' are not accepted.

Data Types: char

Output Arguments

collapse all

Month of date, returned as a nonnegative integer.

Three letter abbreviation for month, returned as a character vector.

See Also

| |

Introduced before R2006a

Was this topic helpful?