[Rails] Re: Finding distinct months using find_by_sql

2008-09-24 Thread pepe
To display the month name you could either: 1. Create a function that would return the month name based on the month numeric value and call it from your SQL statement. This would allow you to use the same functionality in more than 1 statement, or... 2. Use a case clause. Not sure how the syntax

[Rails] Re: Finding distinct months using find_by_sql

2008-09-23 Thread it
Thanks for the reply Johannes. I think you're right about Postgresql not supporting monthname(). I managed to get round this using the following: @headlines_month = Headline.find_by_sql("SELECT DISTINCT DATE_PART('year', date) as year, DATE_PART('month', date) as month FROM headlines ORDER BY ye

[Rails] Re: Finding distinct months using find_by_sql

2008-09-23 Thread Johannes J. Schmidt
Hi, it looks like your Postgresql doesn't support the function monthname(). Try this statement on a Postgresql-console. Which Version of Postgresql do you have installed? Greetings Johannes Am Dienstag, den 23.09.2008, 10:43 -0700 schrieb it: > Hello, > I'm wondering if someone might be able to