0

I have a date range as;

start_day = Date.parse("2017-02-15")
last_day = Date.parse("2017-02-17")

I would like to get records as;

@availabilities = Availabilities.where(date: start_day..last_day)

But the thing here is, it looks for the records in between. I need to check for 15 & 17 as well. Because when I use this, it returns nil. However, I have a record for 2017-02-15.

Thank you.

Uday kumar das
  • 1,615
  • 16
  • 33
Shalafister's
  • 761
  • 1
  • 7
  • 34
  • 1
    If `Availabilities.where(date: start_day..last_day)`is exclusive, just do ```start_day = Date.parse("2017-02-15") - 1 last_day = Date.parse("2017-02-17") + 1``` – Makushimaru Mar 21 '18 at 11:53

1 Answers1

1

Use this code:

@availabilities = Availabilities.where("date >= ? AND date <= ?",start_day,last_day)
Uday kumar das
  • 1,615
  • 16
  • 33