我想通过 created_at 属性选择一系列模型记录,我试过这个查询
Client.where('created_at BETWEEN ? AND ?', 30.days.from_now, DateTime.now.utc)
但它返回一个空数组。
1.9.3-p125 :029 > Client.where('created_at BETWEEN ? AND ?', 30.days.from_now, DateTime.now.utc)
Posting Load (1.0ms) SELECT `clients`.* FROM `clients` WHERE (created_at BETWEEN '2012-09-22 16:30:04' AND '2012-08-23')
=> []
另外我想使用.day
方法将这些记录分组到数组数组中,我的意思是如果我有 10 条记录,我想将在同一天创建的记录分组到单独的数组中!