Precision of datenum()

Dear,

due to some time discrepancy during experimental measurements,
I am currently investigating the difference between several time stamps.

These time stamps are generated via some LabWindows/CVI software, but the analysis I’d like to do with Scilab.

Two different time stamps are logged:

  • time stamp from Windows system … logged up to milli seconds
    e.g.: YYYY, MM, DD, hh, mm, ss, ms

  • time stamp generated by counting CPU ticks … logged up to micro seconds
    e.g: YYYY, MM, DD, hh, mm, ss, ms, micros

In Scilab I would like to compare both time stamp using serial time
serialTime = datenum(...)

Now, I am not sure if datenum() handles only full seconds, so: What is correct ?

1.)
sec = ss + ms / (10^3) + micros / (10^6)
serialTime = datenum(YYYY, MM, DD, hh, mm, sec)

or

2.)
serialTime = datenum(YYYY, MM, DD, hh, mm, ss)
serialTime = serialTime + ms / (10^3) + micros / (10^6)

I assume it is 1.), but I do not know if datenum() truncates / rounds the seconds to “full seconds”.

Thank you,
Philipp

Hello,

datenum() does not truncate/round the seconds. You can use the case 1.

y = 2025;
m = 2;
d = 19;
h = 15;
mm = 41;
ss = 25;
ms = 506; 
micros = 474
sec = ss + ms / (10^3) + micros / (10^6)
datenum(y, m, d, hh, mn, sec)
datevec(datenum(y, m, d, hh, mn, sec))
1 Like