I have a DailyQuote model in my rails application which has a date and price for a stock. Data in the database has been captured for this model
require 'date'
today = Date.today
ask_price_for = (today.wday == 6) ? today - 1 : (today.wday == 0) ? today - 2 : today
or
require 'date'
today = Date.today
ask_price_for = (today.saturday?) ? today - 1 : (today.sunday?) ? today - 2 : today
ask_price_for
now holds a date for which you would want to ask the price for.
Getting the actual price which is corresponding to you date depends on your Model and your ORM-Library (i.e. ActiveRecord).