【问题标题】:Mysql Error Code : 1292 Incorrect datetime value : ''Mysql 错误代码:1292 日期时间值不正确:''
【发布时间】:2014-03-21 16:36:53
【问题描述】:

我正在尝试向表中插入一条记录,但出现以下错误。

Mysql Error Code : 1292 Incorrect datetime value : ''

Mysql代码snip-let如下

插入 tbl_dashboard (avg_response) SELECT cast(ifnull(floor(avg(5 * (DATEDIFF(substring(im.inq_managerreply,-10), im.inq_managerdate) DIV 7) + MID('0123444401233334012222340111123400001234000123440', 7 * WEEKDAY(im.inq_managerdate) + WEEKDAY(substring(im.inq_managerreply,-10)) + 1, 1))),'not_applicable')AS CHAR(45))'average_response_time_in_working_days' FROM inq_manager 我

执行 select 语句时没有错误,它给出了不包括周末的平均响应时间,但是当我尝试将上述内容插入到我的表中时,给出了错误。 tbl_dashboard 的数据类型是 avg_response char(45)

我该如何克服这个。请帮忙

【问题讨论】:

  • 我想说这是我见过的最丑陋的查询。不幸的是,事实并非如此。
  • 可能,你需要修改你所做的任何事情的整个逻辑

标签: mysql datediff insert-into


【解决方案1】:

我不确定这是否重要,但值得一试。如果它没有帮助,我会删除它,但也许

INSERT INTO tbl_dashboard (avg_response) VALUES
(SELECT cast(ifnull(floor(avg(5 * (DATEDIFF(substring(im.inq_managerreply,-10), im.inq_managerdate) DIV 7)
       + MID('0123444401233334012222340111123400001234000123440',
                        7 * WEEKDAY(im.inq_managerdate) + WEEKDAY(substring(im.inq_managerreply,-10)) + 1, 1))),'not_applicable')AS CHAR(45)) 'average_response_time_in_working_days'
  FROM inq_manager im)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-15
    • 2017-10-24
    • 2021-11-11
    • 2014-05-13
    • 2014-06-28
    • 2017-08-26
    • 1970-01-01
    相关资源
    最近更新 更多