Sequel で今月のエントリのリストを復元したいと考えています。
私は試した:
Entry.where(:date >= Date.month).sum(:duration)
また
Entry.where(:date.like('%/06/2013')).sum(:duration)
などの方法がありましたが、どれもうまくいかないようでした。
現在の月と今年のすべてのエントリが必要な場合は、おそらく範囲を使用するのが最も簡単です。
d = Date.today
Entry.where(:date=> Date.new(d.year, d.month)...(Date.new(d.year, d.month) >> 1)).sum(:duration)
任意の年の現在の月が必要な場合、Sequel にはこれに対するサポートが組み込まれています。
Entry.where(Sequel.extract(:month, :date) => Date.today.month).sum(:duration)