Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created December 24, 2013 03:28
Show Gist options
  • Save lxneng/8108415 to your computer and use it in GitHub Desktop.
Save lxneng/8108415 to your computer and use it in GitHub Desktop.
select quarter for current year by number in Ruby
scope :by_quarter, lambda { |quarter|
date = Date.new(Date.today.year, quarter * 3)
where created_at: date.beginning_of_quarter..date.end_of_quarter }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment