且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

OSQL中的OrientDB日期操作以找到同一天但不同年份的节点的路径

更新时间:2023-11-23 20:36:28

我在看到 Alessandro 在我的旧问题中做了什么.我正在添加我的解决方案用于存档目的.希望它可以帮助需要在 OSQL 查询中进行日期操作的其他人.

I got it working after seeing what Alessandro did in my old question. I'm adding my solution for archival purposes. Hopefully it might help others down the line who need to do date manipulation within OSQL queries.

这是我最后的结果:

MATCH {CLASS: A, AS: A1} -edgeTypeA->
    {AS: B} <-edgeTypeA-
    {AS: A2, WHERE: ($matched.A1.Date.format('yyyy').asInteger()=sum($currentMatch.Date.format('yyyy').asInteger(),-1) AND
                     $matched.A1.Date.format('MM-dd')=$currentMatch.Date.format('MM-dd') ) }
RETURN A1,A2

而且我得到了适合我的数据的东西:

and I get the right thing for my data:

+----+------+------+
|#   |A1    |A2    |
+----+------+------+
|0   |#49:30|#49:32|
|1   |#55:44|#56:46|
|2   |#53:0 |#53:2 |
|3   |#55:20|#55:22|
|4   |#49:42|#49:44|
|5   |#50:32|#50:34|
+----+------+------+

不得不调用 sum 的感觉有点像()asInteger() 但现在我明白了它并且可以使用它.

It kind of feels like a lot to have to make the call to sum() and asInteger() but now I understand it and can work with that.