_time timestamp with millisecond resolution

Hello,

I’m using an external BI tool to generate some reports with data coming from queries to Influx api.
The tool requires joda time format - millisecond not nanosecond resolution.
It seems the date.truncate options provide a rounding function, but I need a trimming function.

Without any modifications, my query result looks like:

,result,table,_time,count,version
,_result,0,2022-01-12T18:27:46.981462017Z,some data....

I’ve found a way to do it by adding this flux, but is there an easierr inbuilt way I’m missing?

  |> map(fn: (r) => ({"version":r.version,"count":r._value, _time:string(v: now())}))
  |> map(fn: (r) => ({ r with _time: strings.substring(v: r._time, start: 0, end: 23) }))
  |> map(fn: (r) => ({ r with _time: strings.joinStr(arr: [r._time, "Z"],v:"")}))

gives what I need:

,result,table,_time,count,version
,_result,0,2022-01-12T18:23:48.165Z,some data etc

Thanks,
Tom

I use pretty much the same, just condensed into one map call

|> map(fn: (r) => ({ r with _time: strings.substring(v: string(v: r._time), start: 0, end: 23) + "Z" }))

Thanks @alespour , I didn’t know you could do + “Z”, I’m copying your condensed solution!