Reputation: 57
I am using golang in my application.I m using beego framework to create it.I use beego ORM to do the database operations.I do the following
num, err := o.Raw("UPDATE apply_leave SET leavestatus=?,resultdate=?
WHERE leaveid=?",leaveResult.LeaveResult, time.Now(),leave_id).Exec()
When i run this i m getting the following error
"Error 1292: Incorrect datetime value: '15:46:59' for column 'resultdate' at row 1"
Please do note that the resultdate is of type timestamp.Appreciate any help...
Upvotes: 0
Views: 2025
Reputation: 7091
You may format it as format time as "2006-01-02 15:04:05"
explicitly
Changing your code as follows will help
const MySQLTimeFormat = "2006-01-02 15:04:05"
num, err := o.Raw("UPDATE apply_leave SET leavestatus=?,resultdate=?
WHERE leaveid=?",leaveResult.LeaveResult, time.Now().Format(MySQLTimeFormat),leave_id).Exec()
Upvotes: 1