Displaying 1 result from an estimated 1 matches for "headlines_month".
2008 Sep 23
3
Finding distinct months using find_by_sql
...stinct years and months to display in
a view something like what might be seen under the ''Archives'' section
of a blog page, like this:
September 2008
August 2008
July 2008
etc.
I have tried to set the following sql statement in my controller to
find the months using find_by_sql:
@headlines_month = Headline.find_by_sql("SELECT distinct
MONTHNAME(date) FROM headlines")
However, this errors out as:
PGError: ERROR: function monthname(date) does not exist at character
17
HINT: No function matches the given name and argument types. You may
need to add explicit type casts.
: SELECT...