Dates in Squeryl

528 views
Skip to first unread message

Brian Vaughan

unread,
Feb 4, 2011, 11:55:07 PM2/4/11
to Squeryl
Hi,

Anywhere to find more detailed examples of Squeryl usage?

Currently I'm struggling to figure out how to use dates... I know I
can use java.util.Date as a "Primitive" date, but maybe there's some
non-primitive date as well? Since java.util.Date is mostly
deprecated, should we really be using it?

The specific query I'm trying to write in squeryl right now is one to
fetch all rows for a certain day... without caring about the time of
day (the time isn't stored in my DB)

In postgres I can write queries like:
select * from mytable where extract(year from thedate)=2010 and
extract(month from thedate)=2 ....

How would I write this kind of query using Squeryl?

Thanks,
-brian

Dustin Withers

unread,
May 25, 2012, 12:18:02 PM5/25/12
to squ...@googlegroups.com
I'm looking for the exact same thing. I really need the ability to use a where clause on a date extract from PostgreSQL. I could store the day of weeks on the row itself but Postgres has this nice feature. Is it possible that I could extend Squeryl to support his easily? Or Is this already possible?

Thanks,
-dustin

Maxime Lévesque

unread,
May 25, 2012, 1:11:26 PM5/25/12
to squ...@googlegroups.com

You can create a custom function :

   http://squeryl.org/custom-functions.html

Or, you can you can use : 

  where(d.between(d1, d2))

where d1 and d2 is the lower and upper bound of your date range.


2012/5/25 Dustin Withers <fade...@gmail.com>



--
Seuls les poissons morts nagent avec le courant
Reply all
Reply to author
Forward
Message has been deleted
0 new messages