Skip to main content
1-Visitor
March 6, 2018
Solved

Export Data Widget with millisecond timestamp

  • March 6, 2018
  • 2 replies
  • 8753 views

My mashup shows the table for valuestream, using queryPropertyHistory correctly, including the timestamp in millisecond format.

 

However, My problem is that when I export the table using the export widget, the resulting CSV file does not show the time stamp in milliseconds, the exported format is different from the mashup in this regard.

 

How can I export an infotable, which has timestamp in yyyy-MM-dd HH:mm:ss.SSS 

 

Thanks

 

 

 

Best answer by CarlesColl

Build a custom service and with Derive snippet build the desired result, for instance if you want unix timestamp:

 

var result = Resources["InfoTableFunctions"].DeriveFields({

   types: "LONG",

   t: originalInfoTable,

   columns: "timestamp",

   expressions: "myDateTimeField.getTime()"

  });

 

2 replies

22-Sapphire I
March 6, 2018

One way you can do this is to create the payload server side and then use WriteCSV to write it to a file repository and then download the file to the client.

mtyago1-VisitorAuthor
1-Visitor
March 7, 2018
I am using docker version(client and server on same machine) of Thingworx and I am not sure how to access the repository.
22-Sapphire I
March 7, 2018

The System comes with the SystemRepository - FileRepository by default.

you can create any number of new ones with the FileRepository ThingTemplate

Each comes with ootb services to do: GetDirectoryStructure and GetFileListingWithLinks those can be used as rest calls, or even in composer test or even better build a FileRepository browser to see files in a Repository and Download the actual files.

Attaching a very simple one

1-Visitor
March 7, 2018

Build a custom service and with Derive snippet build the desired result, for instance if you want unix timestamp:

 

var result = Resources["InfoTableFunctions"].DeriveFields({

   types: "LONG",

   t: originalInfoTable,

   columns: "timestamp",

   expressions: "myDateTimeField.getTime()"

  });

 

1-Visitor
March 23, 2018

Hi,

Quick question, I have a result set coming from SQL all the timestamps (we have > 10 columns that are timestamps with ms).
I send the result of that into the Data export widget but as mentioned before, we are not getting millisecond in the file.

 

Doing DeriveFields creates new field base on x value. 

How can I just, with the same result from the result set, transform the date time type so we can have the ms in the file as opposed to create new columns?

 

I tried the service that creates a file and then you link the download file but it was missing some columns & value thus we don't want to use that.

PS: There is no datashape assign to the service and Columns have spaces. The service is "Dynamic" / Shapeless. 

1-Visitor
March 23, 2018

You can Derive with the same name as the original one, what I mean if if your DATETIME fieldName it's timestamp, you can derive and set timestamp as the resulting field and it will be overwitten.