Reputation: 13
.joins(:residence) .where('(custom_services.date_from - ?) <= 1', Date.today)
Does anyone know how to correctly implement a check the difference between the date in custom_services.date_from and today's is less than or equal to one day(in the screenshot, one of the attempts is not correct)
Upvotes: 0
Views: 48
Reputation: 15258
Using Date.tomorrow
and beginless range:
.where(date_from: ..Date.tomorrow)
if need to specify table name
.where('custom_services.date_from': ..Date.tomorrow)
Upvotes: 2
Reputation: 16
you can just use
.where('custom_services.date_from <= ?', Date.today + 1.day)
Upvotes: 0
Reputation: 169
Can you use something like this?
where("DATEDIFF(custom_services.date_from, ?) <= 1", Date.today)
Upvotes: 0