Try:

Ticket.count(:group => 'date(created_at)', :having =>
['date(created_at) >= ? and date(created_at) <= ?', "2010-09-14",
"2010-10-13"])

HTH

On Fri, Oct 15, 2010 at 11:20 AM, Lee Smith <[email protected]> wrote:

> Query:
> Ticket.count(:group => 'date(created_at)', :having =>
> ['date_created_at >= ? and date_created_at <= ?', "2010-09-14",
> "2010-10-13"])
>
> Successful MySQL 5.1.41 output:
>
> SELECT count(*) AS count_all, date(created_at) AS date_created_at FROM
> `tickets` GROUP BY date(created_at) HAVING date_created_at >=
> '2010-09-14' and date_created_at <= '2010-10-13'
>
> PostgreSQL 8.4.5 error:
>
> ActiveRecord::StatementInvalid (PGError: ERROR:  column
> "date_created_at" does not exist
> LINE 1: ...FROM "tickets"  GROUP BY date(created_at)  HAVING
> date_creat...
>                                                             ^
> : SELECT count(*) AS count_all, date(created_at) AS date_created_at
> FROM "tickets"  GROUP BY date(created_at)  HAVING date_created_at >=
> '2010-09-14' and date_created_at <= '2010-10-13' )
>
> Many thanks for the help!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
Erol M. Fornoles
http://github.com/Erol
http://twitter.com/erolfornoles
http://ph.linkedin.com/in/erolfornoles

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to