Finding the end date of each month in my own sequence of dates

Dear all,
I have the following sequence of dates ("mm/dd/yy" format).
dates = ['01/01/97'
'01/23/97'
'01/27/97'
'01/31/97'
'02/06/97'
'02/07/97'
'02/10/97'
'02/21/97'
'02/24/97'
'02/27/97'
'03/11/97'
'03/27/97'
'03/28/97'];
I would like to find the end date for each month ('01/31/97','02/27/97','03/28/97'). Please note, that the end date of each month does not correspond to the calender end date of each month. So, simply using the "eomday" or "eomdate" function won't work.
Thanks a lot!

 Accepted Answer

dat=datevec(dates)
[~,idx]=unique(dat(:,1:2),'rows','last')
res=dates(idx)

More Answers (0)

Categories

Products

Community Treasure Hunt

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

Start Hunting!