I have following types of documents in mongodb.
{
"id" : 1,
"type" : "temp",
"cdate" : "2017-08-10T06:49:12Z"
},
{
"id" : 2,
"type" : "test",
"cdate" : "2017-06-15T06:49:16Z"
},
{
"id" : 3,
"type" : "cricket",
"cdate" : "2017-07-10T06:49:20Z"
},
{
"id" : 4,
"type" : "rcon",
"cdate" : "2017-06-20T06:49:22Z"
},
{
"id" : 5,
"type" : "health",
"cdate" : "2017-09-05T06:49:25Z"
},
{
"id" : 6,
"type" : "report",
"cdate" : "2017-08-10T06:49:29Z"
},
{
"id" : 7,
"type" : "normal",
"cdate" : "2017-08-10T06:49:39Z"
}
From above documents i have cdate in ISO format.I want to filter cdate on month-date base, not on the year.we can do this query in MySQL via DATE_FORMAT(cdate,'%m-%d') .Below is a MySQL query that wants to convert into MongoDB query.
SELECT * FROM `temp`
WHERE DATE_FORMAT(cdate,'%m-%d')
BETWEEN DATE_FORMAT('2022-06-01','%m-%d') and
DATE_FORMAT('2022-08-15','%m-%d');
kindly let me know is there any way or any operator like date_format
in mongodb
so that I can make the same query like above MySQL query.