fjgarcia
(Javier García)
September 14, 2021, 9:02am
1
Hi,
I am using version 20.11.3
I want to query the nodes within a certain month
I have this index
created: datetime @index (month) .
The date data I have has this format:
“2021-03-11T18:08:28Z”
I have this query
@filter (eq(created, [“10”]))
but i get this error:
“message”: ": Got error: parsing time “10” as “2006-01-02T15:04:05”: cannot parse “10” as “2006” while running: name:“eq” args:“10” ",
“extensions”: {
“code”: “ErrorInvalidRequest”*
}
I do not have any in my nodes with the year 2006.
Do I have something wrong with my query?
On the other hand, could you ask: give me all the nodes of the day “Friday” or “Saturday”, etc.?
Thank you.
MichelDiz
(Michel Diz)
September 14, 2021, 5:20pm
2
You have to use the format RFC3339
e.g. 2006-01-02T15:04:05.999999999+10:00
That’s not possible. There’s no calendar control as far as I know.
amaster507
(Anthony Master)
September 14, 2021, 10:20pm
3
Here may be some more context:
Hardly ever do I need to find a node by the exact date to the second which is what the eq filter does.
Most often I need to find nodes that match dates based upon the hour, day, month, year.
Right now to do any of these we have to use the between filter.
Use Case Example
type Task {
id: ID
name: String
due: DateTime @search
}
query thisHour {
queryTask(filter: { due: {
# eq: "2020-03-10T12"
between: { min: "2020-03-10T12:00:00", max: "2020-03-10T12:59:59" }
} }) {
id
}…
fjgarcia
(Javier García)
September 15, 2021, 2:42pm
4
Hi,
Thank you both for your answer.
I think that to get the nodes of a specific day of the week I am going to calculate the day in my Java application and when I insert the node I will insert it in a different predicate than the date.
Regards
1 Like