怎么获取datetime数据类型的日期

  • nebula 版本:2.0.1

如题

https://docs.nebula-graph.com.cn/2.0.1/3.ngql-guide/3.data-types/4.date-and-time/#date

看下这个文档呢?

发帖之前文档以及论坛上的相关帖子已经研读过了,现在的业务场景是:图库中创建某一个的tag,该tag有一个属性creatTime(数据类型是dateTime,时间精度到秒),查询时需要搜索 creatTime 落在某一个日期范围的数据,例如要搜索 [2021/3/18, 2021/3/18] 内的数据,只要图库中的tag creatTime 日期符合条件即可

1 个赞

要对 datetime 做一个判断是嘛

是的

(czp@nebula) [nba]> create tag A(a datetime)
Execution succeeded (time spent 4952/5255 us)

(czp@nebula) [nba]> insert vertex A(a) values "1":(datetime("2021-11-08T13:56:32.000"))
Execution succeeded (time spent 3211/3516 us)

(czp@nebula) [nba]> create tag index a_index on A(a)
Execution succeeded (time spent 5210/5484 us)

(czp@nebula) [nba]> rebuild tag index a_index
+------------+
| New Job Id |
+------------+
| 5          |
+------------+
Got 1 rows (time spent 7363/7749 us)

(czp@nebula) [nba]> match (v:A) where v.a>datetime("2021-11-08T13:56:32.000") return v
+---+
| v |
+---+
+---+
Empty set (time spent 11210/11569 us)

(czp@nebula) [nba]> match (v:A) where v.a>datetime("2021-11-08T13:56:31.000") return v
+-----------------------------------------+
| v                                       |
+-----------------------------------------+
| ("1" :A{a: 2021-11-08T13:56:32.000000}) |
+-----------------------------------------+
Got 1 rows (time spent 14280/14659 us)

(czp@nebula) [nba]> match (v:A) where v.a>datetime("2021-11-08T13:56:31.000") and v.a<datetime("2021-11-09")return v
+-----------------------------------------+
| v                                       |
+-----------------------------------------+
| ("1" :A{a: 2021-11-08T13:56:32.000000}) |
+-----------------------------------------+
Got 1 rows (time spent 8845/9229 us)

此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。