0

I have a student node with the below props.

{hopper=[true], updatedDate=[Fri Sep 16 09:28:40 UTC 2022], userId=[9c40uvdqkjjmcv4c7f4u3m7gpv],  firstName=[Mounika], lastName=[Mandadi], vLabel=[Student]}

I need to query out all the student nodes whose updatedDate is less than a given date.

Queries I have tried:

 g.V().has("Student","updatedDate",gt("Fri Sep 17 09:28:40 UTC
 2022")).count()

This havent worked. What is the correct way to query? What index is preferrable for date comparision queries?

Thirumal
  • 8,280
  • 11
  • 53
  • 103
  • Is the updatedDate property a string? What is the output of g.V().hasLabel("Student").limit(1).values("updatedDate").next().class – HadoopMarc Sep 17 '22 at 10:07

1 Answers1

0

You really have two main options when storing dates (timestamps) and you need to compare them. I'll mention a third option at the end.

  1. Use actual datetime objects from the client programming language (or use the Gremlin datetime function if sending queries as text.
  2. Use epoch integers (13 or 10 digit), so the time of this answer would be 1663599168.

You can also use strings if all you need to do is gt and lt type operations but the strings need to carefully conform to the ISO 8601 standard format; such as : 2022-09-19T14:57Z

I prefer to use either real datetime objects or epoch integers as they are easier to deserialize to code and allow additional operations such as subtraction to find timestamp deltas.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38