Hi there.  I'm trying to get Sequel.extract working to measure the duration 
between a queried field value and Time.now.

This is what I've been trying: (:creation_date is the date field)
# start = Date.today - 421
puts Sequel.extract(:day, Sequel.cast(Time.now, Date) - Sequel.cast(:
creation_at, Date)).as(:age)  # reference: alpha

puts Sequel[Time.now - Sequel.cast(:creation_at, Date)].extract(:day) # 
reference: bravo

Corresponding sql for PostgreSQL:

EXTRACT(day FROM (SELECT now()-creation_at)) AS age

Alpha comes up with a numeric expression but I can't seem to get anything 
out of it.  Bravo gives me errors.  I thought this would have resulted in a 
hash such as:

{:age => 421}

I'm assuming this type of extraction can be pulled out of a duration, 
seeing that this is a PostgreSQL aspect rather than Sequel.

Cheers

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/55c02b19-eeaf-4ef7-98ec-4b8376201ed3%40googlegroups.com.

Reply via email to