Date comparisons

632 views
Skip to first unread message

jstorm

unread,
Nov 14, 2012, 6:16:12 PM11/14/12
to gremli...@googlegroups.com
I am using OrientDB as my data store.
 
If I grab a property containing a date from my database in the gremlin console, I get output like this:
 
gremlin> g.v('8:4').created
==>Wed Nov 14 23:00:26 EST 2012
 
With gremlin, how can I do date comparisons? For example, I would like to filter{} a bunch of selected vertices by the date and exclude ones below a certain threshold. Will I need to parse the date myself and use lots of logic to do the comparison or is there a simpler way?
 
Cheers :)

Stephen Mallette

unread,
Nov 14, 2012, 6:44:49 PM11/14/12
to gremli...@googlegroups.com
consider converting dates to a long value and/or ISO 8601

http://www.w3.org/TR/NOTE-datetime

Stephen
> --
>
>

jstorm

unread,
Nov 14, 2012, 9:21:34 PM11/14/12
to gremli...@googlegroups.com
Hi Stephen,
 
Do you mean storing the datetime as a long initially or parsing and converting in the query? OrientDB recognises datetime fields, so when grabbing a vertex/edge, I can process it and convert it into a datetime() object in PHP (which makes it easier to deal with dates and times). I would prefer to keep it that way.
 
Will have suffer performance issues if I do the conversion when running queries (how efficient is groovy/gremlin at doing this)?
 
Cheers :)

Stephen Mallette

unread,
Nov 15, 2012, 6:51:10 AM11/15/12
to gremli...@googlegroups.com
I prefer storing the long primitive over a complex java object (even
though some graph implementations allows that). A long is portable
across languages and easily comparable. I believe that conversion to
a date time object in any language with subsequent formatting should
be reasonably inexpensive, though I would encourage you to test
several different ways of doing it. Sometimes, I've even stored both
in the database as two separate properties: the long and a string
ISO8601.

stephen
> --
>
>
Reply all
Reply to author
Forward
0 new messages