Given a particular date, calculate how many months must pass before that same day of the month occurs on the same day of the week.

Start with 22-Oct-2014, which is a Wednesday. How many months must pass before the 22nd of the month occurs on a Wednesday again? Answer: You have to wait for six months. 22-Apr-2015 is also a Wednesday.

Example

 d_in = '22-Oct-2014'
 wait_in_months = 6

Feature Tip

This problem is made simpler by the DATETIME objects found in MATLAB Release 2014b and later.

Solution Stats

344 Solutions

131 Solvers

Last Solution submitted on Jan 05, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers131

Suggested Problems

More from this Author54

Problem Tags

Community Treasure Hunt

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

Start Hunting!