On Monday, January 6, 2020 at 9:48:07 AM UTC-8, BeeRich33 wrote:
>
> Any chance I can get some leadership on that statement?  It's one *WHERE* 
> clause I need to use.  
>
> WHERE creation_date::date > (CURRENT_DATE) - interval '30 days'::date
>
> *:creation_date* is a timestamp field.  It's tripping up on the *'30 
> days'* part.  I'm assuming I do not need any coercing to timestamp or 
> datetime types.  
>
> .where(:creation_date > (CURRENT_DATE - interval '30 days')
>
> Cheers
>

"interval" in that context operates similarly to a cast, so this should 
probably work:

.where(Sequel.cast(:creation_date, Date) > Sequel.cast(Sequel::CURRENT_DATE 
- Sequel.cast('30 days', :interval), Date)) 

Thanks,
Jeremy

-- 
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/9f19a321-f1f5-490b-8abe-9ee96aed3e6d%40googlegroups.com.

Reply via email to