RDT is not displaying the date column values correctly


#1

Hello guys, in this case I am having a problem with an RDT, the thing is that this table is showing the values of an index created in Elasticsearch, which contains a property of type date with a format of epoch_millis, something like this:

 {
      index: "epoch-millis-index",
      body: {
        mappings: {
          properties: {
            date: {
              type: "date",
              format: "epoch_millis",
            },
          },
        },
      },
    },

So when the table shows the data, the column that belongs to the date is not formatted to a real date, instead it shows “Invalid Date”. The following image is an example of how it is showing now:

image

And what I want is to show the formatted date, as in this image for example:
image

Please if you could help me with a guide to where the problem is, I would appreciate it.

Thanks.


#2

Hi @wrulh88, thank you for writing to us, please to be able to help you with your problem I need you to make a request to your index using postman for example, to do some verifications on the data.

The result of a query like this (http://localhost:9200/epoch-millis-index/_search) will be enough.

Thanks.


#3

Hi @juan.dominguez, thank you for answered me, after the execution of the request, i got the below:

{
    "took": 9,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 143,
            "relation": "eq"
        },
        "max_score": 1.0,
        "hits": [
            {
                "_index": "epoch-millis-index",
                "_type": "_doc",
                "_id": "VTcMEHoBtHe5hxtIH4JO",
                "_score": 1.0,
                "_source": {
                    "date": "1623766865620"
                }
            },
            {
                "_index": "epoch-millis-index",
                "_type": "_doc",
                "_id": "VjcMEHoBtHe5hxtIH4JO",
                "_score": 1.0,
                "_source": {
                    "date": "1623766865622"
                }
            },
            {
                "_index": "epoch-millis-index",
                "_type": "_doc",
                "_id": "VzcMEHoBtHe5hxtIH4JO",
                "_score": 1.0,
                "_source": {
                    "date": "1623766865637"
                }
            },
            {
                "_index": "epoch-millis-index",
                "_type": "_doc",
                "_id": "WDcMEHoBtHe5hxtIH4JO",
                "_score": 1.0,
                "_source": {
                    "date": "1623766865653"
                }
            }
        ]
    }
}

Thank you for your help.


#4

Hi @wrulh88, thank you so much for send me the request result. I was able to reproduce your scenario successfully, in your case the problem is that you are saving the epoch millis as an string, thats the reazon why you can’t see the dates formatted. Try saving the value without convertion to string and should work. Instead of "date": "1623766865620" should be "date": 1623766865620.

I hope I have helped you with this answer. If you have any other questions, do not hesitate to ask us.

Thanks.


#5

Thank @juan.dominguez you very much, I tried what you suggested and it worked perfectly.