Use WhereRaw with DateDiff

2

I need to get the difference in days between the current date and the date stored in the database, subtract this difference by 90 and then check if the result is equal to 7. Where is the error?

whereRaw("90 - (DATEDIFF(now(), 'updated_at')) = 7")
    
asked by anonymous 30.10.2017 / 22:49

1 answer

1

It would not be like this, that is, the field updated_at without quotes, because it is a field of your table:

whereRaw("(90 - (DATEDIFF(now(), updated_at))) = 7")
    
30.10.2017 / 23:05