A datetime always has an hour, minute, second component. The display format of the datetime array may be such that it is not shown, but it is always there. If you've read that array from a text file which didn't have a time component, then it defaults to 00:00:00.
You have several options to compare datetime arrays using just the date
- You could set the time component in a to 00:00:00 and use standard comparison functions (e.g. ismember, or join)
- You could extract the year, month and day from each with ymd and do array comparison (e.g. with ismember with the 'rows' option)
- You could extract the date as strings (using char or datestr) and compare the strings.
Going with option 2, you could do:
ymda = zeros(height(a), 3);
[ymda(:, 1), ymda(:, 2), ymda(:, 3)] = ymd(a.Datetime);
ymdb = zeros(height(b), 3);
[ymdb(:, 1), ymdb(:, 2), ymdb(:, 3)] = ymd(b.Date);
queryresult = b(ismember(ymdb, ymda, 'rows'), :);
Best Answer