Model class objects that are not columns in the database

I have a model Day with table days and column date, which holds a ruby
and mysql date object respectively. How do I create a model object,
date.year, without creating a column ‘year’ in the data table, days?
How do I create this global class variable in the model from an
encasulated data field? Will this give me the dynamic find method,
find_by_year?

Sam

The following code is surely not working as it is, as i cant even
remember the proper format of a DATE column in mysql from the top of my
head, but maybe it helps to push you in the rioght direction:

def find_by_year(year)
find :all, :conditions => [“date >= ‘?-01-01’ AND date <=
‘?-12-31’”,year,year]
end

def year
self.date.year
end

that should enable you to do something like:

Model.find_by_year(2001)

and

SomeModelInstance.year