0

I have an array of, say, end of month datenum in Matlab. I am looking for a function to check if the dates are consecutive. Consider the following array of dates:

Dates = [datenum(2000,1:10,eomday(2000,1:10)),datenum(2000,12,31),datenum(2001,1:2,eomday(2001,1:2))];

datestr(Dates)

ans =

31-Jan-2000
29-Feb-2000
31-Mar-2000
30-Apr-2000
31-May-2000
30-Jun-2000
31-Jul-2000
31-Aug-2000
30-Sep-2000
31-Oct-2000
31-Dec-2000
31-Jan-2001
28-Feb-2001

where the 30-Nov-2000 is missing. I would like a functionality to identify that 31-Jan-2000 to 31-Oct-2000 are consecutive, that 30-Nov-2000 is missing, and that 31-Dec-2000 to 28-Feb-2001 are consecutive.

Any ideas??

1
  • use datevec and check the months. Commented Apr 29, 2015 at 8:28

1 Answer 1

2

You can convert your dates to serial numbers using datenum, then you can do a diff on it and find values greater than the datenum of your desired interval.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.