On May 20, 12:49 am, Jeremy Evans <[email protected]> wrote:
> On May 19, 9:30 pm, simon <[email protected]> wrote:
>
> > I wanna translate the TIMESTAMPDIFF( , , , ) function into sequel
> > type, which i try the query below but got something wrong:
>
> > dataset.filter(...).select
> > ( :TIMESTAMPDIFF.sql_function( SECOND , :fund_histories__created_at, :
> > fund_histories__updated_at) )
>
> > which come out the SECOND in the mysql is kind of CONSTANT of second,
> > but in ruby , it treat it as a Class.
> > when i try SECOND.sql_function with no parameter input, it translate
> > to SECOND(), sequel treat it as a function. both of above tries was
> > not success.
>
> > I wanna know anybody encounter this or even want to use this mysql
> > function, but got confuse the same with me ?
>
> This should work:
>
>   select{timestampdiff('SECOND'.lit, fund_histories__created_at,
> fund_histories__updated_at)}
>
> You have to use a literal string to get the SECOND part.  The other
> change is from using sql_function to a virtual row block, but that's
> optional, the only necessary change is using the literal string.
>

:SECOND might work too, this works on SQL
server :datepart.sql_function(:hh, :created_at)

-- 
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.

Reply via email to