Created
December 24, 2013 03:28
-
-
Save lxneng/8108415 to your computer and use it in GitHub Desktop.
select quarter for current year by number in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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