Date Comparison Matlab Urgent Help Needed !!!

2 views
Skip to first unread message

notorious_neo

unread,
Mar 25, 2010, 1:49:33 PM3/25/10
to MATLAB Pool
hey all,
I have been trying to search how to compare two dates in
matlab. My problem is i have data for the FTSE 100 stocks and like
always its incomplete and inconsistent. I have loaded dates for all
stocks in a matrix and they are not in the correct format:
20030101 20030101 20040923 20030101
20030102 20030102 20040924 20030102
20030103 20030103 20040927 20030103
... and so on (stocksDates array)

I have corrected the format my problem is i need to compare dates,
like 02/01/2003 > 01/01/2003. i have tried datenum but the numbers u
get cant be compared in this manner cause i get the following

734655 for 30/01/2009
734140 for 13/02/2009
733806 for 02/02/2009

here clearly in numbers 734655 for 30/01/2009 > 734140 for 13/02/2009
which is not the case. my code for this conversion is as follows:
in=find(stocksDates(:,1));
no=max(in);
V=num2str(stocksDates(1:no,1));
dtYear=V(1:no,1:4);
dtMonth=V(1:no,5:6);
dtDay=V(1:no,7:8);
sepDate(1:no,1)='/';
correctDate=[dtDay,sepDate,dtMonth,sepDate,dtYear];
dtev=datevec(correctDate);
dtnum=datenum(dtev);

i use no=max(in); and in=find(stocksDates(:,1)); because i dont have
the same data for all stocks i.e. some stocks have more data hence
more dates and some have less. i want to get stock data for all stocks
(about 102) in a certain range (01/01/2003 to say 01/01/2009) and drop
out stocks that do not have data in this range. therefore i need to
compare dates.

Urgent help would really be appriciated.

Reply all
Reply to author
Forward
0 new messages