Kboyz
Kboyz

Reputation: 189

Bigquery Invalid Timestamp

I was trying to update the table but I got this error instead:

Error 400: Invalid timestamp: '2021-03-02 05:34:51.161346 +0000 UTC', invalidQuery])

How do I convert this to timestamp?

Here's the code:

ctx := context.Background()
client, err := bigquery.NewClient(ctx, projectID)
if err != nil {
    return fmt.Errorf("bigquery.NewClient: %v", err)
}
defer client.Close()

q := client.Query("UPDATE myTable SET name = "John Doe", date_updated = TIMESTAMP("2021-03-02 05:34:51.161346 +0000 UTC") WHERE id = 10"

Upvotes: 1

Views: 3459

Answers (1)

Sergey Geron
Sergey Geron

Reputation: 10172

Try

q := client.Query("UPDATE myTable SET name = 'John Doe', date_updated = TIMESTAMP('2021-03-02 05:34:51.161346') WHERE id = 10"

To set timezone use +00:

q := client.Query("UPDATE myTable SET name = 'John Doe', date_updated = TIMESTAMP('2021-03-02 05:34:51.161346+00') WHERE id = 10"

Upvotes: 1

Related Questions