gocql
gocql copied to clipboard
QUERY ACCORDING TO DATE CONDITION
For example:
1) lastdate value is static ('2022-08-31 11:08') .
iter := Session.Query("SELECT * FROM students where lastdate>'2022-08-31 11:08' and firstname=? ALLOW FILTERING", name).Iter();
2) lastdate is variable and using in query.
lastdate := "2022-08-31 11:08"
iter := Session.Query("SELECT * FROM students where lastdate>? and firstname=? ALLOW FILTERING", lastdate, name).Iter()
What is problem in this query?
Do you get an error from the iterator? Please provide more context how you call the query and what the schema is.
Without more information my guess would be that you are trying to marshal a Go string into a timestamp cql type, which is not supported (see table at https://pkg.go.dev/github.com/gocql/gocql#Marshal). You could try using time.TIme
, for example lastdate:=time.Date(2022,8,31,11,8,0,0,nil)
Hi Martin no error in this query result or iterator. I haven't been try your example yet but I'll let you know when i try. Thank you for answer.