Get documents between two dates

The problem is your filter expression '2021-12-01' <= DATE_FORMAT(d.created_on, "%yyyy-%mm-%dd") <= '2021-12-05' This is basically the same as

LET x = '2021-12-01' <= DATE_FORMAT(d.created_on, "%yyyy-%mm-%dd")
FILTER x <= '2021-12-05'

x is a bool and as such always compares less than a string.

You should rewrite your query as follows:

FOR d IN mycollection
  LET date = DATE_FORMAT(d.created_on, "%yyyy-%mm-%dd")
  FILTER '2021-12-01' <= date AND date <= '2021-12-05'
  SORT d.created_on ASC 
  RETURN DATE_FORMAT(d.created_on, "%yyyy-%mm-%dd")

This should filter correctly, but you won't be able to utilize any indexes on created_an for the FILTER, only for the SORT. So instead it would be better to write the query as follows:

LET from = DATE_TIMESTAMP('2021-12-01')
LET to = DATE_TIMESTAMP('2021-12-05')
FOR d IN mycollection
  FILTER from <= d.created_on AND d.created_on <= to
  SORT d.created_on ASC 
  RETURN DATE_FORMAT(d.created_on, "%yyyy-%mm-%dd")