Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
日時フィールドの時刻でレコードをクエリするにはどうすればよいですか?そして「時間」とは、日付のない時間を意味します。たとえば、任意の日の深夜に作成されるすべてのレコードが必要です。
このように:
Product.where("time(created_at) = time(?)", Time.new(2008,6,21, 24,0,0, '-00:00'))
編集
TimezoneパラメータをTime.newに追加しました。このパラメータは、データベースに日時フィールドがあるタイムゾーンと一致する必要があります。
Product.where("created_at like ?", "%00:00:00%")