Re: [Neo4j] Date datatype with NEO4J?

4,449 views
Skip to first unread message

Michael Hunger

unread,
Apr 5, 2013, 5:13:49 AM4/5/13
to ne...@googlegroups.com
Currently not, people store dates in seconds or ms since 1970 or in a comparable textual representation (20131230144505) so it is sortable.


With cypher there are arithmetic ops
There are also options for timeline indexes or tree graph structures to represent time.




Sent from mobile device

Am 05.04.2013 um 01:41 schrieb Rodger <rodg...@gmail.com>:

Hello,

Oracle has a great date datatype composed of (I believe) 7 bytes. 
The range is from January 1, 4712 BCE through December 31, 9999 CE,
which includes EVERY second in that range. 

They also have a number of built in date functions such as 
months_between, add_months, last_day, next_day.   


Does NEO4J have a Date datatype, or object?



Thanks a lot!

Rodger

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Rodger

unread,
Oct 27, 2013, 1:29:50 PM10/27/13
to ne...@googlegroups.com
Just to clarify then. 

Does NEO4J have a datatype, java.util.Date, not? 

The PDF Neo4j Manual v2.0.0-M06, in section 3.3. Properties, does not list the Date. 

BTW, searching the PDF for "datatype", and "data type" returns no hits.

Axel Morgner

unread,
Oct 27, 2013, 3:23:34 PM10/27/13
to ne...@googlegroups.com
Hi Rodger,

there's no Date datatype in Neo4j, as only the Java primitives and their arrays are supported in the core API. Typically, date values are stored as Long values.

However, afaik, all language drivers and frameworks around Neo4j have support for a real date datatype.

Best regards
Axel
--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


--

Axel Morgner
CEO Structr (c/o Morgner UG) · Hanauer Landstr. 291a · 60314 Frankfurt · Germany
Twitter: @amorgner
Phone: +49 151 40522060
Skype: axel.morgner

Structr - Award-Winning Open Source CMS and Web Framework based on Neo4j
Structr Mailing List and Forum
Graph Database Usergroup "graphdb-frankfurt"

Rodger

unread,
Oct 29, 2013, 1:53:41 PM10/29/13
to ne...@googlegroups.com
Hello all, 

I've been looking at this thread, the example, and the manual for over an hour now.

Looking at this link, http://docs.neo4j.org/chunked/milestone/cypher-cookbook-path-tree.html ,
it's just to show how to work with tree structures, not dates, correct?
It has three fields to store year, month, day. No time of day component.


In Oracle SQL, using Date datatype, querying a similar date range is only 2 lines:

WHERE  event.event_date >= to_date ( 'yyyy-mm-dd', '2010-12-31'  )
and         
event.event_date <= to_date ( 'yyyy-mm-dd', '2011-01-03'  )


I've been searching the NEO4J manual for "date".
Unless you are using a java program, I can't see how to do something similar to this SQL example in Cypher.

In Cypher, it seems you would have to know the Long or string representation of the date first.
And in Cypher, there are no memory variables to store these values, correct?
More processing steps, and/or lines of code.


One of my RDBMS tuning secrets was to do all the processing in the database.
Not in external programs (read data into program, process in program, write back).
http://rodgersnotes.wordpress.com/2010/09/14/oracle-performance-tuning/


Dates and calendars are always more difficult to work with in any language.
They are not linear like integers or real numbers.
The number of days changes each month.
And every four years, the number of days in the year changes.


A Date object will never allow any incorrect dates to be input into it.
Unlike storing numbers as strings, where you can input "@",  not "2".
The insert will work, but a query will fail.
http://rodgersnotes.wordpress.com/2010/09/21/muck-massively-unified-code-key-generic-three-table-data-model/


Oracle has some fabulous SQL functions to work with dates.

Most common: Sysdate, To_date, To_char, Trunc
Also: Last_day (of the month), Next_day,  Add_months, Months_between
Number of days between is simply:  Select trunc(sysdate) - trunc(date1)


I've found this functionality to be incredibly useful.

I can't imagine how much work it would have been to build RDBMS systems without the Date datatype and the associated functions.



When you think of it, Graph databases are useful, because it stores and represents objects similar to a graph, as a graph.
In those cases, it's better than using tables or other datatypes, objects, structures.

Applying the same concept, why not store and represent dates, as Dates?

I think adding Date objects and functions so that Cypher can query / manipulate dates in nodes and relationships directly, is very important.
Critical even.

Hope it's useful.

Best,

Rodger

Michael Hunger

unread,
Oct 29, 2013, 3:29:53 PM10/29/13
to ne...@googlegroups.com
Neo4j has not built in date support.

Am 29.10.2013 um 18:53 schrieb Rodger <rodg...@gmail.com>:

Hello all, 

I've been looking at this thread, the example, and the manual for over an hour now.

Looking at this link, http://docs.neo4j.org/chunked/milestone/cypher-cookbook-path-tree.html ,
it's just to show how to work with tree structures, not dates, correct?
It has three fields to store year, month, day. No time of day component.

You can add as many levels as you want, down to milli or nanoseconds whatever makes sense for your domain.


In Oracle SQL, using Date datatype, querying a similar date range is only 2 lines:

Right but a graph is no relational database and so needs some different approaches when it comes to set operations.

But I think such a to_date (or general convert function makes a lot of sense, please raise a GitHub issue for that for cypher)


WHERE  event.event_date >= to_date ( 'yyyy-mm-dd', '2010-12-31'  )
and         
event.event_date <= to_date ( 'yyyy-mm-dd', '2011-01-03'  )


I've been searching the NEO4J manual for "date".
Unless you are using a java program, I can't see how to do something similar to this SQL example in Cypher.

In Cypher, it seems you would have to know the Long or string representation of the date first.

Yep if you want to compare them storing them in a comparable format makes sense.

And in Cypher, there are no memory variables to store these values, correct?

what are memory variables?

More processing steps, and/or lines of code.

What do you mean?



One of my RDBMS tuning secrets was to do all the processing in the database.
Not in external programs (read data into program, process in program, write back).
http://rodgersnotes.wordpress.com/2010/09/14/oracle-performance-tuning/

Yep, that's what we try too. 

Michael


Dates and calendars are always more difficult to work with in any language.
They are not linear like integers or real numbers.
The number of days changes each month.
And every four years, the number of days in the year changes.


A Date object will never allow any incorrect dates to be input into it.
Unlike storing numbers as strings, where you can input "@",  not "2".
The insert will work, but a query will fail.
http://rodgersnotes.wordpress.com/2010/09/21/muck-massively-unified-code-key-generic-three-table-data-model/


Oracle has some fabulous SQL functions to work with dates.

Most common: Sysdate, To_date, To_char, Trunc
Also: Last_day (of the month), Next_day,  Add_months, Months_between
Number of days between is simply:  Select trunc(sysdate) - trunc(date1)


I've found this functionality to be incredibly useful.

I can't imagine how much work it would have been to build RDBMS systems without the Date datatype and the associated functions.



When you think of it, Graph databases are useful, because it stores and represents objects similar to a graph, as a graph.
In those cases, it's better than using tables or other datatypes, objects, structures.

Applying the same concept, why not store and represent dates, as Dates?

I think adding Date objects and functions so that Cypher can query / manipulate dates in nodes and relationships directly, is very important.
Critical even.

Hope it's useful.

Best,

Rodger

Reply all
Reply to author
Forward
0 new messages