I have a table in cassandra which looks like this:

create table dailyusage(
  name string
  service string
  date  date

I need to write a query in Go using gocql package to filter the results 
from dailyusage table based on a user provided date range

I have created my query like this

startDate := "2018-04-01"
endDate  := "2018-04-03"

var name, service string
var date time.Time

qstr := `SELECT name, service, date, FROM dailyusage WHERE date >= ? and date 
<= ?`

iter := ss.Query(qstr, startDate, endDate).Iter()

for iter.Scan(&name, &service, &date) {

  // add to my list


if err := iter.Close(); err != nil {

  fmt.Printf("Error closing iterator:%v \n", err)


When I run this, I am getting error - 

Error closing iterator. Error:can not marshal string into date

If I change startDate and endDate to time.Time format, I am getting this 
below error

Error closing iterator. Error:can not marshal time.Time into date

Is there any way to address this conversion from string/Time in golang to date 
format in cql/gocql?



You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to