A year containing a date or not

How can I check a year containing a specified date or not.
eg. 2050 contain a as a sunday in a date 30.
input is like: 1,2050(januvary 2050)
output : true because it contain 30 as a sunday

2 件のコメント

madhan ravi
madhan ravi 2020 年 7 月 3 日
If that month contains 30 as sunday?
Silpa K
Silpa K 2020 年 7 月 3 日
Yes. Then the output is true or not it became false.
another eg: 5, 2010
output false, when in 2010th december is not sunday in the date 30.

サインインしてコメントする。

回答 (3 件)

KSSV
KSSV 2020 年 7 月 3 日

0 投票

Fromhere you can pick the required column,(first column corresponds to Sunday) and check whether the given day is present or not.
Walter Roberson
Walter Roberson 2020 年 7 月 3 日

0 投票

year = 2050; month = 1;
has_sunday30 = weekday(datetime(year, month, 30)) == 1;

2 件のコメント

Silpa K
Silpa K 2020 年 7 月 3 日
Thank you .
I need to take the input from user.
Walter Roberson
Walter Roberson 2020 年 7 月 3 日
input(). Or menu(). Or inputdlg() together with str2double() . Or use some popups or listboxes.

サインインしてコメントする。

madhan ravi
madhan ravi 2020 年 7 月 3 日

0 投票

strcmp(string(datetime(2050,30,1,'format','eeee')),"Sunday")

2 件のコメント

Silpa K
Silpa K 2020 年 7 月 3 日
Thank you .
I need to take the input from user.
madhan ravi
madhan ravi 2020 年 7 月 3 日
Use input() for 2050 and 1.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

タグ

質問済み:

2020 年 7 月 3 日

コメント済み:

2020 年 7 月 3 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by