Skip to content

Instantly share code, notes, and snippets.

@jonasporto
Last active March 16, 2016 23:52
Show Gist options
  • Save jonasporto/26108e71d8f4c253f5fd to your computer and use it in GitHub Desktop.
Save jonasporto/26108e71d8f4c253f5fd to your computer and use it in GitHub Desktop.
Working with date ruby
http://stackoverflow.com/questions/8511919/how-to-scope-last-week-by-date-object
https://nandovieira.com.br/trabalhando-com-datas-no-ruby-on-rails
https://nandovieira.com.br/formatando-datas-no-ruby-on-rails
Date.today.beginning_of_month
scope :completed_at_last_week, -> {
where(
completed_at: 1.week.ago.beginning_of_week..1.week.ago.end_of_week
)
}
scope :completed_at_last_month, -> {
where(
completed_at: 1.month.ago.beginning_of_month..1.month.ago.end_of_month
)
}
completed_at: Date.today.beginning_of_month..Date.today.end_of_month
Date.today.beginning_of_week(start_day = :sunday)
Date.today.end_of_week
Date.today.end_of_week(end_day = :saturday)
Date.today.end_of_week(end_day = :sunday)
Date.today.end_of_week(:sunday)
dsfdsfdsfdsfds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment