Skip to content

Instantly share code, notes, and snippets.

@Will-Sommers
Created August 13, 2013 14:04
Show Gist options
  • Save Will-Sommers/6221436 to your computer and use it in GitHub Desktop.
Save Will-Sommers/6221436 to your computer and use it in GitHub Desktop.
def gen_sql
relation = Set
@recipient ||= "company"
@date_window ||= "1year"
case @date_window
when "1day"
relation = relation.from_to(Time.now - 1.days, Time.now)
when "1week"
relation = relation.from_to(Time.now - 7.days, Time.now)
when "1month"
relation = relation.from_to(Time.now - 1.month, Time.now)
when "3month"
relation = relation.from_to(Time.now - 3.months, Time.now)
when "6month"
relation = relation.from_to(Time.now - 6.months, Time.now)
when "1year"
relation = relation.from_to(Time.now - 1.year, Time.now)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment