Skip to Content
0

Timestamp and miliseconds in IoT Service

Feb 05 at 07:13 AM

52

avatar image

Hi,

when using the IoT Service on SAP NEO platform, the predefined "date" datatype does not allow for miliseconds. It only allows integer type timestamps.

How could we account for smaller time intervalls ?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Anton Levin
Feb 05 at 07:40 AM
0

Hello Marcus,

"date" type [1] in the IoT Service Neo could either a Unix time, represented as seconds since January 1, 1970 or represented as ISO 8601-compatible string. An example with milliseconds is "2016-01-14T08:01:02.123Z"

Regards,

Anton

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi,

thanks. I tried it and post to IoT like

{"timestamp":"2019-05-11T12:59:04.999Z"}

but i see in HANA db only seconds

Sat May 11 2019 12:59:04 GMT+0000 (UTC)

What am I missing ?

0

I guess this is just a matter of how HANA Cockpit represents the value. MMS Application Data (UI5) does the same, by the way:

If you consume it with MMS OData API, the the value is exactly what you are expecting for:

<entry>
  <id>
https://iotmms***.hanatrial.ondemand.com:443/com.sap.iotservices.mms/v1/api/http/app.svc/T_IOT_M0T0Y0P0E1(G_DEVICE='d000-e000-v000-i000-c000-e001',G_CREATED=datetime'2018-02-07T14%3A00%3A41.231',C_SENSOR='sensor1',C_VALUE='21',C_TIMESTAMP=datetime'2019-05-11T12%3A59%3A04.999')
  </id>
  <title type="text">T_IOT_M0T0Y0P0E1</title>
  <updated>2018-02-07T14:09:29.782Z</updated>
  <category term="com.sap.iotservices.mms.entity0" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
  <link href="T_IOT_M0T0Y0P0E1(G_DEVICE='d000-e000-v000-i000-c000-e001',G_CREATED=datetime'2018-02-07T14%3A00%3A41.231',C_SENSOR='sensor1',C_VALUE='21',C_TIMESTAMP=datetime'2019-05-11T12%3A59%3A04.999')" rel="edit" title="entity0"/>
  <content type="application/xml">
    <m:properties>
      <d:G_DEVICE>d000-e000-v000-i000-c000-e001</d:G_DEVICE>
      <d:G_CREATED>2018-02-07T14:00:41.231</d:G_CREATED>
      <d:C_SENSOR>sensor1</d:C_SENSOR>
      <d:C_VALUE>21</d:C_VALUE>
      <d:C_TIMESTAMP>2019-05-11T12:59:04.999</d:C_TIMESTAMP>
    </m:properties>
  </content>
</entry>

0

I consume it with a web service from a view in HANA to display in Analytics Cloud. However neither the data in the db nor the service data show the miliseconds. Also in the service test screen I cannot post the miliseconds. If I e.g. your format proposal, the HANA DB shows:

The message was

{"mode":"sync","messageType":"m0t0y0p0e1","messages":[{"sensor":"sensor1","value":"20","timestamp":"2019-05-11T12:59:04.999Z"}]}

unbenannt.png (4.2 kB)
0