How to Match Different Formatted Date Strings from Multiple Tables

1 view (last 30 days)
Hello, I need help with date strings.
I have 2 tables, Table 1 has timeseries with this time format: i.e. 2000-06-02_00:00:00
And Table 2 has this time format: i.e. 02.06.2000 (day/month/year)
I have to create a loop starting from "2000-06-02" with 1 day increments for next 5 days, then find the matching row number on Table 2's date column, then parse the needed data from the corresponding row number on another column, but I am stuck at finding the correct functions for the task. I wrote the following part of my code but got a "DATENUM Failed, caused by Cannot parse date' error.
On code "time" is time column of Table 1, and "obstime" is of Table 2.
Any help is much appreciated.
Thanks in advance.
P=24;
D=5;
for N=1:D
if N == 1
Date{N}=datenum(datestr(datenum(time(1,1)),'dd.mm.yyyy'));
y=find(obstime,Date{N});
Obs_out(N)=PtData(y);
Day_out(N,1)=mean(A(1:23));
elseif N > 1
d=Date{N-1};
dn=datenum(datestr(d+1));
y=find(obstime,dn);
Obs_out(N)=PtData(y);
S=P+23;
Day_out(N,1)=mean(A(P:S));
P=S+1;
  2 Comments
Thomas
Thomas on 26 Sep 2012
Why are you going from datenum-datestr-datenum
b1={'02.06.2000'}
datenum(b1,'DD.MM.YYYY')
ans =
730487.00
Works just fine..
Al Onen
Al Onen on 26 Sep 2012
I knew there was some problem over there :). Also which function should I use to locate the time step on 2nd table?

Sign in to comment.

Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!