Pq: erroneous array literal: "2024-04-05 00:00:00Z"

in the postgres database

{"2024-04-05 00:00:00","2024-04-10 00:00:00"}
func qSchBkg(w http.ResponseWriter, conn *sql.DB,start time.Time,end time.Time) (rows *sql.Rows, err error) {

    fmt.Println("qSchBkg start.. ", start)
    // start,end print 2024-04-06 00:00:00 +0000 UTC 2024-04-07 00:00:00 +0000 UTC
    rows,err = conn.Query("SELECT * FROM booking WHERE days_booking BETWEEN $1 AND $2", start,end)

    if err != nil {
        switch {
            case true:
            fmt.Fprintf(w, "Error: Query()..! : %+v\n", err)
            break
        }
        return
    }
    return rows,err
}

Try to running the same query in a postgress database client to see what error is returning the database

are the fields in the DB WITH TIMESTAMP ?

as suggested by @Yamil_Bracho , try to run in a SQL prompt and check the results

this is clearly not a “Go” issue and a Postgre issue. Or better yet a misunderstanding of how Postgres works with types such as Time. It is not as simple as matching strings in the database. The string you get back is NOT the way it is stored or compared in the database. You need to study up on Postgres and how it actually works internally.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.