week

Week of the year for each datetime.

Category: Language Fundamentals > Data Types

Syntax

w = week(d)

Returns the week of the year of each date.

Description

The year starts in week 1, which contains January 1. Weeks start on Sunday, so the last days of December can belong to week 53. For example, March 5, 2024 is in week 10.

Use day, month and year for other calendar parts.

Input arguments

d
datetime array.

Output arguments

w
Double array with the week number, 1 to 53.

Example

Week numbers

week(datetime(2024,3,5))
week(datetime(2024,1,1))
Output
ans = 10
ans = 1

See also

day month year datetime weekday