mysql - Problem with mysql2 adapter "group" statement when writing queries -


when run following query in ruby:

transaction.all(:select => "created_at, sum(amount) amount", :group => "created_at.strftime('%y-%m-%d')", :order => 'created_at')  

i following error in mysql2 (works in mysql):

activerecord::statementinvalid: mysql2::error: function created_at.strftime not exist: 

what need group transaction on date(without time). rewrite statement, there can this? thanks!

there date function want.

# mysql> select date('2003-12-31 01:02:03'); #        -> '2003-12-31' # # used in query:  transaction.all(   :select => "created_at, sum(amount) amount",   :group => "date(created_at)",   :order => "created_at")  

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -