getting the day of the week for a given date
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
OLUBUKOLA ogunsola
am 8 Jun. 2016
Kommentiert: Steven Lord
am 9 Dez. 2021
As today is Wednesday with date June 8, 2016. how can i write a code to get the day of given dates: like what day is Nov 29 I'm trying to create a struct with date
day
month
with month and date as input
1 Kommentar
paul Erameh
am 9 Dez. 2021
i actually need something like this that can work for any year. meaning i would input a date and it would tell me the day. please help me out.
Akzeptierte Antwort
Azzi Abdelmalek
am 8 Jun. 2016
Bearbeitet: Azzi Abdelmalek
am 8 Jun. 2016
d='jun-08-2016'
d=datestr(d,'mmm-dd-yyyy')
datestr(d,'mmm-ddd-yyyy')
0 Kommentare
Weitere Antworten (1)
Stephen23
am 8 Jun. 2016
Bearbeitet: Stephen23
am 8 Jun. 2016
>> datestr(datenum('June 8, 2016','mmmm dd, yy'),'dddd')
ans =
Wednesday
>> datestr(datenum('November 29, 2016','mmmm dd, yy'),'dddd')
ans =
Tuesday
But a much better option would be to store the date as date vectors, which makes the processing much simpler:
>> datestr([2016,06,08,0,0,0],'dddd')
ans =
Wednesday
>> datestr([2016,11,29,0,0,0],'dddd')
ans =
Tuesday
9 Kommentare
paul Erameh
am 9 Dez. 2021
i actually need something like this that can work for any year. meaning i would input a date and it would tell me the day. please help me out.
Steven Lord
am 9 Dez. 2021
Use the day function for datetime arrays.
dt = datetime('today')
d = day(dt, 'short')
Siehe auch
Kategorien
Mehr zu Calendar finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!