Error code: 1582 incorrect parameter count in the call to native function ' str_to_date '

Source: Internet
Author: User

1. Error description
1010 warnings查询:SELECT t.`name`, DATE_FORMAT(str_to_date(‘2015‘‘%Y‘03...1582infunction‘str_to_date‘执行耗时   0 sec传送时间   0 sec总耗时      0 sec
2. Cause of Error
SELECTT.' name ', Date_format (Str_to_date (' + '),'%Y ') asStatisdate, ROUND (Ifnull (SUM(T.' Amount '),0),3) asAmount fromT_stu_info TWHERE 1=1    andDate_format (T.statisdate,'%Y ') =' + ' UNION All SELECTT.' name ', Date_format (Str_to_date (' the '),'%Y ') asStatisdate, ROUND (Ifnull (SUM(T.' Amount '),0),3) asAmount fromT_stu_info TWHERE 1=1    andDate_format (T.statisdate,'%Y ') =' the '

The format of MySQL built-in function str_to_date is: str_to_date (string, date format);
In this query SQL is str_to_date (string), resulting in an error

3. Workaround

modifying query SQL statements

SELECTT.' name ', Date_format (Str_to_date (' + ','%Y '),'%Y ') asStatisdate, ROUND (Ifnull (SUM(T.' Amount '),0),3) asAmount fromT_stu_info TWHERE 1=1    andDate_format (T.statisdate,'%Y ') =' + ' UNION All SELECTT.' name ', Date_format (Str_to_date (' the ','%Y '),'%Y ') asStatisdate, ROUND (Ifnull (SUM(T.' Amount '),0),3) asAmount fromT_stu_info TWHERE 1=1    andDate_format (T.statisdate,'%Y ') =' the '

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Error code: 1582 incorrect parameter count in the call to native function ' str_to_date '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.