LoginSignup
0
0

More than 5 years have passed since last update.

RailsのActiveRecordにおける、日付期間の重複チェック

Posted at

参考によると

比較開始日付 <= 対象終了日付 AND 比較終了日付 >= 対象開始日付

で重なっていると判断されるらしいので

matched_dates = Hoge.where('start <= ? and end >= ?', self.start, self.end)

みたいな感じにすればよい

参考:
https://qiita.com/yaju/items/a58a78f41ee41258a5fe

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0