Excellent you have thought of everything ;)
Might be nice to have those examples in the cheat sheet as that is my
primary reference.
I totally missed it in RDoc (as I miss everything else).
Thanks
On Aug 19, 2:31 pm, Jeremy Evans <[EMAIL PROTECTED]> wrote:
> On Aug 19, 2:16 pm, Jim Morris <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi, I'm using Posgresql, and I want to use the extract function, the
> > following works but seems a tad ugly...
>
> > r= db[:transactions].filter({:EXTRACT['year FROM
> > transactions.created_at'.lit] => date.year} & {:EXTRACT['month FROM
> > transactions.created_at'.lit] => date.month} ).all
>
> > Is it possible to do something like the following?
>
> > r= db[:transactions].filter({:EXTRACT['year FROM '
> > + :transactions__created_at] => date.year} & {:EXTRACT['month FROM '
> > + :transactions__created_at] => date.month} ).all
>
> > As it avoids the .lit, and allows me to use the regular sequel syntax
> > for column names.
>
> > Any better solution suggestions are appreciated :)
>
> > MySql allows me to do this: :YEAR[:transactions__created_at] but
> > postgresql doesn't have the year function.just that ugly EXTRACT[part
> > FROM expr]
>
> There's special support for
> extract:http://sequel.rubyforge.org/rdoc/classes/Sequel/SQL/ComplexExpression...
>
> From the RDoc:
>
> Extract a datetime_part (e.g. year, month) from self:
>
> :date.extract(:year) # SQL: extract(year FROM date)
>
> ComplexExpressionMethods is a module included in Symbol (and some
> other classes).
>
> Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-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/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---