strftime error while switching my database from sqlite3 to mysql in Rails4

后端 未结 2 549
长情又很酷
长情又很酷 2020-12-07 06:11

Recently i changed my database from sqlite3 to mysql.When i ran my project i am getting this error in one of the file which is using this query.

date = Date.today +

相关标签:
2条回答
  • 2020-12-07 06:19

    Try this with simply replace,

    <% @employees = Employee.where("status = ? AND strftime('%d/%m', date_of_birth) = ?", "Active" , date.strftime('%d/%m')) %>
    

    With

    <% @employees = Employee.where("status = ? AND DATE_FORMAT(date_of_birth,'%d/%m') = ?", "Active" , date.strftime('%d/%m')) %>
    
    0 讨论(0)
  • 2020-12-07 06:41

    There is no strftime function in MySQL. Use DATE_FORMAT instead.

    See Convert DateTime Value into String in Mysql for more examples.

    0 讨论(0)
提交回复
热议问题