1

我想向不是今天生日的其他人发送通知邮件。我已经使用代码找出今天过生日的人......

控制器代码:

@people = Person.find(:all, :conditions => ["DAY(date) = ? AND MONTH(date) = ?", Date.today.day, Date.today.month])

现在,我如何修改它以获取生日人以外的人?

4

3 回答 3

1

@people = Person.where('DAY(date) <> ? OR MONTH(date) <> ?', Date.today.day, Date.today.month)

于 2013-01-18T06:05:18.893 回答
1

当然应该是:

@people = Person.where('DAY(date) <> ? AND MONTH(date) <> ?', Date.today.day, Date.today.month)

使用 OR 它将排除今天当天的其他月份和当前月份的其他日期的人。

于 2013-01-18T18:24:44.820 回答
0
@people = Person.where("extract(month from date) != ? AND extract(day from date) != ?", Date.today.month, Date.today.day)
于 2019-06-20T14:01:20.860 回答