mardi 24 novembre 2020

Weird time.beginning_of_month rails 3 behavior

I am working on this query:

Student.where(created_at: time.beginning_of_month..time). Let's say the time here is: `15/10/2020 00:00:00`

I thought this is supposed to return the created students from 1/10/2020 00:00:00 to 15/10/2020 00:00:00 because time.beginning_of_month returns 1/10/2020 00:00:00

However, it returns me the created students from 30/09/2020 22:00:00 to 15/10/2020 00:00:00

I have checked with other months and I get the same results. Somehow, it always returns me the records starting from the last day of the previous month, not the first day of the current month

I am using Rails 3.2.2 and Ruby 2.1.5

Aucun commentaire:

Enregistrer un commentaire