[N] = weeknum(___,W,E) returns
the week in year using the optional input arguments for W and E.
The weeknum function considers the week containing
January 1 to be the first week of the year.
Determine the week of the year using a serial date number.
N = weeknum(728647)
N = 52
Determine the week of the year using a character vector.
N = weeknum('19-Dec-1994')
N = 52
Determine the week of the year using a datetime array.
N = weeknum(datetime('19-Dec-1994','Locale','en_US'))
N = 52
The first week of the year must have at least four days in it. For example, January 8, 2004 was a Thursday. The European standard is used because the first week of the year is the first week longer than three days.
The default start day of the week is Sunday. Every day after, and including the first Sunday of the year (04-Jan-2004), returns 2 denoting the second week. In this case, the first of week of the year started before January 1, 2004. You can also use weeknum with datenum and specify a D value of 5 to indicate that the weeks start on Thursday.
The first week of the year that has four or more days, based on the specified start day, is considered week one (even if this is not the first week in the calendar). Any day falling in (or before) this week is given a week number of 1.
D — Date to determine week in year serial date number | data character vector | datetime array
Date to determine week in year, specified as a serial date number,
date character vector, or datetime array.
Serial date numbers can be a matrix. Date character vectors
can be specified as a one-dimensional cell array of character vectors.
All the date character vectors must have the same format.
Use the function datestr to
convert serial date numbers to formatted date character vectors.
Data Types: single | double | char | datetime
W — Day a week begins 1 (default) | integer with value 1 through 7 | vector of integers with values 1 through 7
Day a week begins, specified as an integer or a vector of integers
from 1 through 7.
1 — Sunday (default)
2 — Monday
3 — Tuesday
4 — Wednesday
5 — Thursday
6 — Friday
7 — Saturday
The weeknum function considers the
week containing January 1 to be the first week of the year.
Data Types: single | double
E — Flag indicates if week of year display is European standard 0 (default) | numeric with values 1 or 0
Flag indicates if week of year display is European standard,
specified as 1 (to use the European standard) or 0 (not
to use the European standard).
The European standard considers first week of year to be first
week longer than three days, offset by the given week’s start
day.
N — Week number of the year, given D numeric | column vector
Week number of the year, given D, returned
as a numeric value, given D, a serial date number,
date character vector, or datetime array. If D is
a one-dimensional cell array of character vectors, then weeknum returns
a column vector of M week numbers, where M is
the number of character vectors in D.
If the optional input arguments W and E are
defined, the week of the year is in the European standard.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.