Topic: Subtracting DATETIME's in a :condition statement?

  I want to be able to search for clients in a MySQL table whose information hasn't been updated for an arbitrary amount of time, ranging from days to weeks.  Is it possible to do something along the lines of

Client.find :all, :conditions => "(CURRENT_DATETIME() - clients.modified_at) > #{30.days}"

Is this ludicrous, or is there a better way to do it (like adding another method onto 30.days in order to get it into a format MySQL can read?)

Re: Subtracting DATETIME's in a :condition statement?

Here's how I usually do it. I like to do the actual calculating in Ruby rather than MySQL. But that's just based on Ruby code being prettier wink

date =
Client.find :all, :conditions => ["clients.modified_at > ?", date]

You could do this too if you need a specific number of days I guess.

date = - 30.days