MySQL datetime field error caused by ColdFusion

Source: Internet
Author: User

The error message is:

Unable to convert MySQL date/time value to system. datetime

 

 

Cause:

It is mainly used to insert a date to a MySQL table. If the date to be inserted is not accepted by MySQL, or at 23:59:59, the date field is0/0/0000 0:00:00 AMEspecially when data is dumped from MSSQL or other databases to MySQL.

 

Solution:

1. On the ColdFusion management interface.

2. Select the data source to be modified ). Then edit.

3. On the data source editing page, there is an input box:Connection string.

4. In the input box, enter:Allow zero datetime = true;

5. Save.

 

If it is Asp.net, add it directly to the connection stringAllow zero datetime = true;Just do

 

For ColdFusion, this method only enables cfquery to retrieve data without errors. However, in the result returned by cfquery, all datetime fields return an object. Cannot be called directly.

 

<Cfquery name = "qry_a" datasource = "myds">

Select * from test

</Cfquery>

 

Let's assume that qry_a has a time field called T1.

 

NoAllow zero datetime = trueIf the year is to be displayed

<Cfoutput> # year (qry_a.t1) # </cfoutput>

If there is such a sentence, the processing will become:

<Cfoutput> # qry_a.t1.get_year () # </cfoutput>, which is completely called by Java.

 

This solution is feasible after testing.

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.