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.

week

Syntax

w = week(t)
w = week(t,weekType)

Description

example

w = week(t) returns the week-of-year numbers of the datetime values in t. The m output is a double array the same size as t and contains integer values from 1 to 53.

w = week(t,weekType) returns the type of week number specified by weekType.

Examples

collapse all

t = datetime(2013,05,31):calmonths(3):datetime(2014,06,15)
t = 1x5 datetime array
   31-May-2013   31-Aug-2013   30-Nov-2013   28-Feb-2014   31-May-2014

w = week(t)
w = 

    22    35    48     9    22

Input Arguments

collapse all

Input date and time, specified as a datetime array.

Type of week values, specified as either 'weekofyear' or 'weekofmonth'.

  • If weekType is 'weekofyear', then month returns the week-of-year number. Week 1 is the week in which January 1 falls, even if fewer than 4 days of that week fall in the same year.

  • If weekType is 'weekofmonth', then month returns the week-of-month number. Week 1 in a month is defined as the week in which the first day of the month falls, even if fewer than 4 days of that week fall in the same month.

Extended Capabilities

See Also

| | |

Introduced in R2014b

Was this topic helpful?