Couldn’t use use Sequel.function(:unix_timestamp)? It’s been a few months
since I’ve written DB code, but that seems like it would work.

-a

On Wed, Oct 12, 2016 at 1:09 PM, Alexander Birkner <alex.birk...@gmail.com>
wrote:

> Hello,
>
> we are migrating our existing backend from PHP to Ruby.
> We are using Sequel with Models but we can't do some queries because there
> is no way to use the MySQL function UNIX_TIMESTAMP.
>
> I would like to create a query like this:
>
> Service.where(
>     :field_1 => 0,
>     :field_2 => 0,
>     :field_3 => Service::SERVICE_STATUS_ACTIVE,
> ).where{
>   (suspend_date - Sequel::UNIX_TIMESTAMP) > 0
> }.where {
>   (suspend_date - Sequel::UNIX_TIMESTAMP) < time
>
> }
>
>
> I've seen there is already existing a CURRENT_TIMESTAMP constant but this
> does not work in our case.
> The existing database field is a int instead of a datetime field.
>
> It would be really awesome if Sequel will add the UNIX_TIMESTAMP mysql
> method for Model queries.
>
> I've done it temporary with using a timestamp variable (timestamp =
> DateTime.now.to_i)
> but I would recommend to use the MySQL server time instead of the API
> server time.
>
> Thank you very much!
>
> --
> You received this message because you are subscribed to the Google Groups
> "sequel-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sequel-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to sequel-talk@googlegroups.com.
> Visit this group at https://groups.google.com/group/sequel-talk.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Austin Ziegler • halosta...@gmail.com • aus...@halostatue.ca
http://www.halostatue.ca/http://twitter.com/halostatue

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to