Datetime precision / granularity


#1

I have data with timestamps to ms precision, e.g. 2019-02-18T09:05:00.123

I can from simple tests that javascript DateTime supports this level of precision:

ts = DateTime("2019-02-18T09:05:00.123")
ts.toString() ===> returns back the same value.

However, when I try to store this value into a type with a datetime field, I find that the timestamp is always rounded to the nearest second (up or down depending on value).

x = MyType.make( { datetimefield: ts })
x.upsert()

c3Grid(x.fetch()) ==> returns 2019-02-18T09:05:00**.000**

Is there anyway to preserve the millisecond component?

Paul


#2

@paulyip the data type that you want to use while persisting is

entity type Test scheme name ‘TEST’ {
datetimeField: datetime with millis
}


#3

Declare datetimefield as datetime with millis. For some reasons, the lossy behavior is preferred as default.


#4

@AlexBakic since most of the data that we manage is from sensors that have much higher then millis reading interval and have grossly miss-aligned clocks default does make sense