# Precision of datenum()

**URL:** <https://scilab.discourse.group/t/precision-of-datenum/826>\
**Category:** General usage\
**Created:** [February 18, 2025, 10:06pm UTC](https://scilab.discourse.group/t/precision-of-datenum/826 "2025-02-18T22:06:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [February 18, 2025, 10:06pm UTC](https://scilab.discourse.group/t/precision-of-datenum/826/1 "2025-02-18T22:06:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adeline.carnis](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@adeline.carnis](https://scilab.discourse.group/u/adeline.carnis)\
**Post date:** [February 19, 2025, 2:51pm UTC](https://scilab.discourse.group/t/precision-of-datenum/826/2 "2025-02-19T14:51:51Z")

</div>

Hello,

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

```auto
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))

```
