Converting Date Type To String Type



In my dataset, there is a field which type is date with "dddd" format (Day of Week).
Can I create a scripted field in kibana which contains the value of this field but in the form of string?

For example :
The date field is Start_Date and it equals to Wednesday. How to create "Day Of Week" field (string type)
which contains exactly "Wednesday" but as a string?


(Shaunak Kashyap) #2

Can you share your index's mapping, please, specifically for the Start_Date field?


I hope that I share right thing ( actually I have recently started working with kibana and elasticsearch). Is it what you mean?

(Shaunak Kashyap) #4

I was actually referring to the mapping for the index in Elasticsearch ( but what you have shared is helpful too.

So it looks like you have already formatted the Start_Date field with dddd in Kibana. Why do you need another field that contains the same value? What is your end goal here? Knowing that it might be easier to recommend the right approach.


Actually, I want to count (unique count) of an string field (for example unique count of customer or unique count of Id ) per day of week during a specific time.

And when I am using this field as "Term aggregation" for X-Axis ( because I want to visualize how many customers will be in different week days in order to compare them with each other) , and set "Order By : Unique count of customer" and also order same as below (7 days of week):

The result will be :

Logically this aggregation shows the first 7 days with highest amount of customer and as you can see I have more than one Wednesday (I understand completely the result).

Finally :slight_smile: I want to have 7 bars each belongs to each day of week ( Sunday , Monday ,...) and the height of bars shows sum of customers in each week day during a specific period of time. Then I think I need to consider Start_Date as string in order to solve my problem ( I don't have any vision about any other possibilities)

Thank you so much for your response,

(Shaunak Kashyap) #6

I think the only way to do this is to preprocess your data before indexing. For each document, figure out the day of the week, set it as a new field in the document, and then index the document in Elasticsearch.


Thank you so much for your quick response
I really appriciate it

(system) #8