mardi 28 septembre 2021

How to query the active record filtering by date?

How can I select ALL student students from my database with active status only in the month of May? I couldn't find it in the active record documentation. I only managed to query the students who were created in May, and not ALL students actived....

Student.where(status:'active', created_at: ('2021-05-01'..'2021-05-31')).count

actually, my idea would go something like this:

Student.where(status:'active', datetime: (('2021-05-01'..'2021-05-31')).count

Aucun commentaire:

Enregistrer un commentaire