All Collections
Components
Transformer - Date formatting using split and concat
Transformer - Date formatting using split and concat

Example using split and join to format dates.

Erick Rubiales avatar
Written by Erick Rubiales
Updated over a week ago

Json input:

{
  "data": {
    "DATE": "18/09/1974"
  }
}

Transformer Spec:

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "data": {
        "array_aux": "=split('/',@(1,DATE))",
        "DATE": "=concat(@(1,array_aux[2]),@(1,array_aux[1]),@(1,array_aux[0]))"
      }
    }
    },
  {
    "operation": "shift",
    "spec": {
      "data": {
        "DATE": "&"
      }
    }
  }
  ]

For this formatting, the following "operation" has been used: "modify-overwrite-beta", which allows changing the json.
Command =split to split the date using the character '/' and to create a 3-position array. It is also possible to use regex on the split. See more examples at: 

After the Split, the command =concat gives us the possibility of concatenating array items according to the index.

Output  

{
  "DATE" : "19740918"
}
Did this answer your question?