2016-12-06 01:37
浏览 138


I am using golang and postgreSQL version 9.5.5 in my application. I am using "" as my database driver to connect to the database. One of my fields have the type timestamp with timezone. I would like to update to the current time. So I used the following code:

Note:I m using beego as my framework and use orm to compute my queries.

_, err := o.Raw("UPDATE leave SET resultdate=? WHERE leaveid=?",  time.Now(), leaveResult.LeaveId).Exec()

When I execute this I'm getting the following error:

"pq: invalid input syntax for type timestamp with time zone: \"09:24:29\""

Appreciate any help.

图片转代码服务由CSDN问答提供 功能建议

我在我的应用程序中使用了golang和postgreSQL版本9.5.5。 我使用“”作为数据库驱动程序来连接数据库。 我的一个字段的类型为带时区的时间戳。 我想更新到当前时间。 因此,我使用了以下代码:

注意:我使用beego作为框架,并使用orm计算我的 查询。

  _,err:= o.Raw(“ UPDATE Leave SET resultdate =?WHERE Leaveid =?”,time.Now(),LeaveResult.LeaveId).Exec()


 “ pq:时间戳类型无效的输入语法 带有时区:\“ 09:24:29 \”“ 


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douqi5079
    douqi5079 2016-12-06 03:34

    High probability that DB expects a different date/time format. For example RFC3339. Try saving instead of time.Now() with time.Now().Format(time.RFC3339)

    点赞 评论