Conversion influx retention 168h0m0s to msec

It is possible to request the retention policy of an Influx database, but the result is a time format like 168h0m0s (=autogen). Is there an easy way to convert this format to milliseconds?

168 * 3600 * 1000 = 604,800,000.

some thing like this

[{"id":"9041e396.e08c28","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"168h0m0s","payloadType":"str","x":220,"y":180,"wires":[["56329e1e.a1243"]]},{"id":"56329e1e.a1243","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t$bits := $split($$.payload, /[^\\d]/, 3).$number($);\t($bits[0] * 3600000) + ($bits[1] * 60000) + ($bits[2] * 1000)\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":180,"wires":[["5b7b3dbe.2f2e4c"]]},{"id":"5b7b3dbe.2f2e4c","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":100,"wires":[]}]

Using a change node and a JSONata expression

(
   $bits := $split($$.payload, /[^\d]/, 3).$number($);
   ($bits[0] * 3600000) + ($bits[1] * 60000) + ($bits[2] * 1000)
)

Similar can be done in a Function node.

@E1cid , thanks for your solution. I meant with "easy way"
, if there was a standard function like "Date.parse(), but this will do nicely too.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.