Using Whereraw with Datediff

Asked

Viewed 97 times

2

I need to take the difference in days between the current date and the date stored in the bank, 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")
  • I made an answer give a look I believe that is not quotes there, because it is a field!

1 answer

1


It would not be so, ie the field updated_at no quotes, because it is a field of your table:

whereRaw("(90 - (DATEDIFF(now(), updated_at))) = 7")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.