Cusom date query

Any idea how to transform this query to elasticsearch ? (myDate is a date format coming from the datatabse, we're just transforming it here to a year month only format)

SELECT date_format(myDate,'%Y%m') as custom
FROM table
GROUP BY date_format(myDate,'%Y%m') 
ORDER BY date_format(myDate,'%Y%m')

In other words, how to group by a custom date? How to use the terms agg with a script to group by YYYY-MM rather than YYYY-MM-DD?

Or can I use something else like date_histogram to format a YYY-MM-DD date to YYYY-MM ?

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