comparing datetime objects between two tables.

I would like to edit my question to this:
if we have two tables t1 and t2, both of them have a date variable. t2 have another variable say var2 that we would like to do the following with:
if we compare the dates between t1 & t2 and any matching is found then we would copy the value of var2 corrseponding to that date from t2 and add it to t1. How can we do that?
thaks for giving it a look.

답변 (1개)

Chetan Bhavsar
Chetan Bhavsar 2021년 10월 15일
date1 = datetime('today');
date2 = datetime('yesterday');
date3 = datetime('tomorrow');
date4 = datetime('tomorrow');
date1 == date2
ans = logical
0
date3 == date4
ans = logical
1
date3 == date4 && date1 ~= date2
ans = logical
1
Above Logic is working fine can you share some content of your code like below.
Before if loop print all the variable and send in comment here so that i can have loook
year(currTable.Date)
year(S.date(j))
month(currTable.Date)
month(S.date(j))
day(currTable.Date)
day(S.date(j))
booleanMatrix
if ((year(currTable.Date)==year(S.date(j)) ...
&& month(currTable.Date)==month(S.date(j)) ...
&& day(currTable.Date)==day(S.date(j)) )==booleanMatrix)
%store the value of the variable 'F10_7' accured in that date from
%'S' into currTable
t.flux=S.F10_7(j);
end

댓글 수: 3

MA
MA 2021년 10월 15일
편집: MA 2021년 10월 15일
thanks for replaying back, the output is too large, so you may find them in the txt document attached. it seems that the variables related to the table S are not in the output for some reason. I can tell that the values I got are for the currtable.
what is significance of boolean matrix\?
MA
MA 2021년 10월 15일
편집: MA 2021년 10월 15일
Thanks for following up, I added it for another purpose we can forget about it. but I managed to get rid of this error once I changed "&&" to "&", I am not sure how that would make a difference. But I am still not sure if the comparison is actually working as if the comparison satisfied the column 'flux' should be added to to the tabl t. I edited the text files for the correct output if it would help.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

MA
2021년 10월 15일

편집:

MA
2021년 10월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by