MATLAB: Logical result false when comparing 2 identical times

time data

Hello, i want to compare times and something is wrong and i dont know why. Perhaps something is wrong in the Excel format of the data. but in matlab i think i placed the format of all the time equal.
clear;
clc;
close all;
tabela1 = readtable('galp.xlsx');
tabela2 = tabela1;
[n,m] = size(tabela1);
t_1 = datetime('01-01-2018 02:00','InputFormat','dd-MM-uuuu HH:mm');
t_2 = datetime('01-01-2018 06:00','InputFormat','dd-MM-uuuu HH:mm');
tempo_a_comparar = tabela2{121,1};
t_1
tempo_a_comparar
C = isequal(t_1,tempo_a_comparar)

Best Answer

The extension of the file you've posted does not match your code. The file you've posted appears to be a .xlsx file.
Add :ss.SSSSSSSSS to the end of all your formats. What you will see is this:
t_1 =
datetime
01/01/2018 02:00:00.000000000
tempo_a_comparar =
datetime
01/01/2018 02:00:00.000022949
ans =
-2.2949e-05
My initial reaction was to point out that Excel stores time in units of days since 1900. So in general, timestamps read from Excel are accurate only to about
>> eps(seconds(datetime - datetime(1900,0,0)))
ans =
4.7684e-07
seconds. But since the actual difference is 50 larger than that, I can only assume that what's in the .xlsx file is not what you think it is.