Day of week
Return Day of Week of Date String
Determine the day of the week of December 21, 2012.
D = '21-Dec-2012'; [DayNumber,DayName] = weekday(D)
DayNumber = 6
DayName = 'Fri'
December 21, 2012 falls on a Friday.
Return Full Day Names of Multiple Date Numbers
Return the full name of the day of the week for a vector of serial date numbers.
D = [734999;735015]; DayForm = 'long'; [DayNumber,DayName] = weekday(D,DayForm)
DayNumber = 2×1 5 7
DayName = 2x8 char array 'Thursday' 'Saturday'
Return Full Day Names in Local Language
Return a day name in U.S. English using the
language input argument.
D = 728647; DayForm = 'long'; language = 'en_US'; [DayNumber,DayName] = weekday(D,DayForm,language)
DayNumber = 2
DayName = 'Monday'
In U.S. English, the name of the day of the week is
Return day names in the language of the current locale.
language = 'local'; [DayNumber,DayName] = weekday(D,DayForm,language);
The value of
DayName depends on the locale. For example, in a French locale, the name of the day of the week is
Return Day of Week of Date String in Custom Format
Determine the day of the week for a date specified in the format
datenum inside of
weekday to specify the format of the input text representing a date.
[DayNumber,DayName] = weekday(datenum('Dec.21.2012','mmmm.dd.yyyy'))
DayNumber = 6
DayName = 'Fri'
D — Serial date numbers or text representing dates and times
vector | matrix | character vector | cell array of character vectors | string array | character array
Serial date numbers or text representing dates and times. Date numbers can be specified as a
vector or matrix. Text can be specified as a character vector, a cell array
of character vectors, a string array, or a character array where each row
represents a date. If
D is a cell array of character
vectors or a string array, then it must be 1-by-
D is a character vector, a cell array of character vectors, a string
array, or a character array, then the dates can be in one of the following
For text representing dates in other formats, first convert
the dates to serial date numbers using the
before passing them to
DayForm — Format of output day names
'short' (default) |
Format of the output day names, specified as one of the following values.
|Format of ||Example|
language — Output language of day names
'en_US' (default) |
Output language of day names in
DayName, specified as one of the following
|Language of the current locale|
DayNumber — Value representing day of week
array of integers in the range
Value representing the day of the week, returned as an array
of integers in the range
7 represents Saturday.
Dis a numeric array, then the size of
DayNumberis equivalent to the size of
Dis a cell array of character vectors, then
m-by-1 vector, where
mis equivalent to the length of
DayName — Name of day of week
Name of the day of the week, returned as a character array.
The content of
DayName depends on
DayNamecontains an abbreviated name (for example,
DayNamecontains the full name of the weekday (for example,
m is the number of dates represented in
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Introduced before R2006a