1

Hi I got some UX time like and I can convert this value in the the data time using this:

as DateTime {unit: "milliseconds"} as String {format: 'yyyy-MM-dd hh:mm:ss:SSS'}
{
"test": {
      
        "1669587277000": 90,
        "1669585177000": 6,
        "1669589077000": 9,
        "1669580977000": 0
    }
}

But how I can convert this key of payload in the dateTime and find the maximium value of the dateTime ?

expected outpout:

[
{
"2022-11-27 10:14": 90
}
]

Salim Khan
  • 4,233
  • 11
  • 15
Anonim
  • 81
  • 5
  • 1
    The ask seems to contain two questions. Converting keys should be one and converting a number of milliseconds to a date time should be a different one. – aled Nov 29 '22 at 00:35

1 Answers1

3

You can use the Coercions module to help with this problem or use the standard way of coercing using the way you did.

%dw 2.0
output application/json
import * from dw::util::Coercions
---
[((payload."test" orderBy -$) pluck {
         (toDateTime($$ as Number, "milliseconds")): $
})[0]]
Salim Khan
  • 4,233
  • 11
  • 15