#community-help

Handling Multiple Dates Search with Unix Timestamp in Int64

TLDR Akashchellakumar asked how to search multiple dates with Unix timestamp in int64. Kishore Nallan suggested inter-field filtering and storing timestamps as array of int64 or strings. Akashchellakumar thanked and agreed to try this method.

Powered by Struct AI

1

9
14mo
Solved
Join the chat
Oct 12, 2022 (14 months ago)
Akashchellakumar
Photo of md5-f291ced1bc3cf23e7631bc5253ffb9dc
Akashchellakumar
06:59 AM
Hello guys,
How to handle multiple dates search using Unix timestamp with int64 data type?
Example :
• I have two different booked date slots for the car rental document (Oct 1 to Oct 10
Oct 21 to Oct 30).
• I need to fetch the same car rental document which is available on the specific date(Oct 11 to Oct 20).
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:13 AM
Hmm, this is like an inter-field filtering. Currently we don't have a way to do that. Filtering is applied at a global field context.
Akashchellakumar
Photo of md5-f291ced1bc3cf23e7631bc5253ffb9dc
Akashchellakumar
07:21 AM
Kishore Nallan Global field context in the sense?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
07:27 AM
The filtering looks at all documents matching a value for a field. When you have a range like this, what we really need to do is to apply the filter within that document so that both the start and end date ranges match to the same document.
07:30
Kishore Nallan
07:30 AM
You could try storing the timestamps of each individual day that the car is booked as an array of int64. That way, this car in your example will have 20 values in the array.

Then when you search for the availability of a given date, you have to do != search.
07:30
Kishore Nallan
07:30 AM
But we currently don't support != on numerical fields yet.
07:30
Kishore Nallan
07:30 AM
So you could store the timestamps as string.
07:31
Kishore Nallan
07:31 AM
So a car could have:

"timestamps": ["A", "C", "D"]

where a, c, and d are timestamps as string. Now if you want to check availability for "B", you will do filter_by=timestamps:!=B
Akashchellakumar
Photo of md5-f291ced1bc3cf23e7631bc5253ffb9dc
Akashchellakumar
07:37 AM
Kishore Nallan Thanks for your clarification, Will try it out and get back to you.

1