MATLAB Answers

A year containing a date or not

2 views (last 30 days)
Silpa K
Silpa K on 3 Jul 2020
Commented: Walter Roberson on 3 Jul 2020
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 Comments

madhan ravi
madhan ravi on 3 Jul 2020
If that month contains 30 as sunday?
Silpa K
Silpa K on 3 Jul 2020
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.

Sign in to comment.

Answers (3)

KSSV
KSSV on 3 Jul 2020
Fromhere you can pick the required column,(first column corresponds to Sunday) and check whether the given day is present or not.

  0 Comments

Sign in to comment.


Walter Roberson
Walter Roberson on 3 Jul 2020
year = 2050; month = 1;
has_sunday30 = weekday(datetime(year, month, 30)) == 1;

  2 Comments

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

Sign in to comment.


madhan ravi
madhan ravi on 3 Jul 2020
strcmp(string(datetime(2050,30,1,'format','eeee')),"Sunday")

  2 Comments

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

Sign in to comment.

Tags


Translated by