2

I know I can use a range to search where a date lies between 2 dates. For example:

User.where(:created_at => start_date..end_date )

But how would I do an open ended search for all dates before or after a date?

Thanks for any help

Chris
  • 6,076
  • 11
  • 48
  • 62
  • Possible duplicate of [Can you do greater than comparison on a date in a Rails 3 search?](https://stackoverflow.com/questions/4224600/can-you-do-greater-than-comparison-on-a-date-in-a-rails-3-search) – Brad Werth Mar 29 '18 at 04:25

1 Answers1

9

You can simply to this :

User.where("created_at >= ?", start_date )

Or this

User.where("created_at <= ?", end_date )
Dougui
  • 7,142
  • 7
  • 52
  • 87