0

I try to query item from json storage which datetime property have to be greater than DateTime.UtcNow, here is the example:

var datetime = DateTime.UtcNow;
var obj = json.Get(key, path: $"$.event[?(@.Expires_At>=\"{datetime}\")]");

But it can`t find it. Less than works and returns the data:

var obj2 = json.Get<T>(key, path: $"$.event[?(@.Starts_At<\"{datetime}\")]");

I`ve tried googling how redis handles comparing datetime fields, but there is no right example with greater than(also less than)

Im expecting to find the object that has Expires_At fields value greater than DateTime.UtcNow

Update: The data in the json storage:

  • Starts_At:"2023-06-24T18:54:07.682Z"
  • Expires_At:"2023-06-29T18:54:07.682Z"
  • How have you stored the datetime in the JSON? Perhaps you could share the JSON you have saved. – Guy Royse Jun 27 '23 at 14:22
  • @GuyRoyse Yes, datetime is stored in the json, shared in the desription update – Hlib Dolinin Jun 27 '23 at 19:02
  • I'm not a .NET guy. What is the value that `DateTime.UtcNow` returns? Is it returning the same ISO-8601 formatted string that you are storing in the JSON? – Guy Royse Jun 28 '23 at 14:11

0 Answers0