Filter current month only

I am trying to “filter” to resume only the data during the current month. Has anyone been through this issue

ex.:

obterTodasSaidasCadastro = () => {
const currentMonth = new Date();
const cMonth = currentMonth.getMonth();

.filtered(
saida_cadastro != null AND data_obito == ${cMonth},
),

});

};
even testing manually like this: data_obito = 2021-03-03T00: 00: 00.000Z, did not work
or
data_obito = 2021-03-03, did not work

and in this example, even using template string, it doesn’t work, who knows, could post the solution here,

Thank you very much in advance

got the solution :partying_face:

const firstDay = moment().startOf(‘month’).format(‘YYYY-MM-DD@hh:mm:ss’);
const lastDay = moment().endOf(‘month’).format(‘YYYY-MM-DD@hh:mm:ss’);

let currentMonth = AND BEGINSWITH data_obito == ${firstDay} AND ENDSWITH data_obito == ${lastDay};


let project = Array.from(
realm
.objects(‘Project’)
.filtered(saida_cadastro != null, currentMonth),
);

:rocket:

1 Like