Filter KV by date?

I’m in real need of filtering keys by date, but I’m unable to figure out a clever way to use the prefix to filter between start and end range.

Anyone have any ideas on how to hack this?

EDIT: Figured it out!

Since prefix is text-based it will filter everything that it starts with, but we need some number logic to make sense of it in the KV.

Say we have a key with a March date:

Then we just use the prefix filter:

…to get everything that’s from march and forward.

We also want the end date, so…

Say we have a key value of: [email protected]

Entering the prefix:
[email protected]

Will give us all keys from March to July.

The same logic applies to days.

1 Like

Just a tough, year Decimal, month in hexadecimal, days decimal.

1January 2001

24 October 2019

1 Like

Does that work? Prefix don’t care about sizes of numbers, only what strings begin with.

And I feel it adds a ton of complexity and makes it really hard to reason about.

Of course, doing it the way I suggested create really long keys, but I see no other way.

1 Like