Return the day of the week as a number in n and as a string in s.
The days of the week are numbered 1–7 with the first day being Sunday.
d is a serial date number or a date string.
If the string format is not present or is equal to "short"
then s will contain the abbreviated name of the weekday. If
format is "long"
then s will contain the full name.
Table of return values based on format:
n | "short" | "long" |
---|---|---|
1 | Sun | Sunday |
2 | Mon | Monday |
3 | Tue | Tuesday |
4 | Wed | Wednesday |
5 | Thu | Thursday |
6 | Fri | Friday |
7 | Sat | Saturday |
See also: eomday, is_leap_year, calendar, datenum, datevec.
The following code
## Current weekday [n, s] = weekday (now ())
Produces the following output
n = 2 s = Mon
The following code
## Weekday from datenum input [n, s] = weekday (728647)
Produces the following output
n = 2 s = Mon
The following code
## Weekday of new millennium from datestr input [n, s] = weekday ("1-Jan-2000")
Produces the following output
n = 7 s = Sat
Package: octave