I have the date when an article was created in a DB table. I have articles since the August until today.
I tried to create a SQL query, in ActiveRecord, to get the articles that were created today.
例如,今天是1月14日,我试图将8月14日——9月14日——第14天——产生的条款提交今天。
我试图这样做:
today = Date.today
day = today.strftime( %d )
day_next = (today + 1.day).strftime( %d )
Article.where( created_at >= ? AND created_at <= ? , day, day_next) #day = 14, day_next = 15
但是,这并没有回到正确的说法,因为文章已于12月14日和10月14日发表。 这使我不满意。