Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default MySQL Date issue

    Anyone else have this issue?

    I've got a query that pulls dates out of a MySQL db, and often times the date
    fields have "0000-00-00" in the date field.

    And I get this message "Value '0000-00-00' can not be represented as
    java.sql.Date" when trying to run the query.

    What's up with that? How can I get around that?

    I've got an idea
    IF(thisDate='0000-00-00','',thisDate) as thisDate

    But I'd like my code to be a little cleaner. Any ideas what's wrong? Is this a
    CFMX 7 bug or my bug.

    petron2002 Guest

  2. Similar Questions and Discussions

    1. Date/Time Issue
      The code looks okay. Are "EventTime" and "EventTimeTo" date/time columns in your table? If you output the query values without the LSTimeFormat()...
    2. Date issue
      Any resolution dealing with a simple Access database connection? I'm trying to output users whose birthday is within 5 days plus or minus.
    3. is this a date issue??
      hi all, I have posted this to inetserver.asp.general too..I thought I had crossposted but somehow I didn't, so please accept my apologies if the...
    4. Date issue in php and mysql
      On Mon, 25 Aug 2003 12:59:19 +0200 "Ricki Susic" <rickFJERNDETTEi@webfabrikken.net> wrote: You will have to be a little more specific about...
    5. Date Formatting Issue
      I have Access 2000. On a form, I want to show (in an unbound text box) how long an agreement has been effect, and format it in years and days. ...
  3. #2

    Default Re: MySQL Date issue

    At what point does the error occur? Is the datefield in the select clause? I
    don't work with mySql, but with the databases I do work with, if it ain't a
    valid value, it don't get stored in the first place.

    Dan Bracuk Guest

  4. #3

    Default Re: MySQL Date issue

    Dan,
    The error occurs when I try to run the cfm from the server. Yea, the field is
    in a SELECT inside a cfquery.

    I use the date like that in the db because I've had some problems in the past
    with NULL and no value fields. And so I have MySQL automatically create the
    "0000-00-00" by default when a record is inserted.

    petron2002 Guest

  5. #4

    Default Re: MySQL Date issue

    petron2002,

    Try a google search on your error:

    [url]http://www.google.com/search?hl=en&q=Value+%270000-00-00%27+can+not+be+represent[/url]
    ed+as+java.sql.Date&btnG=Google+Search

    Here's 2 good threads from that search:
    [url]http://lists.mysql.org/java/8210[/url]
    [url]http://forum.java.sun.com/thread.jspa?threadID=649520&messageID=3822351[/url]

    Especially of interest is the last post on the 2nd link:
    "I have just had the same problem when update Mysql from 4.0 to 4.1 and jdbc
    connector from 3.0 to 3.1.7.

    I have solved it adding to the connect url:

    ?zeroDateTimeBehavior=convertToNull

    More info here:

    http://dev.mysql.com/doc/mysql/en/cj-upgrading.html#cj-upgrading-3-0-to-3-1"

    Kronin555 Guest

  6. #5

    Default Re: MySQL Date issue

    YES this is the answer; this just happened to me when i changed my data source
    using the J connector.

    To make a bit more clear what the last post is saying, in the "JDBC URL" just
    add this string "?zeroDateTimeBehavior=convertToNull" to the end of the URL.

    so instead of:

    jdbc:mysql://SERVER.DOMAIN.com:3306/database_name

    you get


    jdbc:mysql://SERVER.DOMAIN.com:3306/database_name?zeroDateTimeBehavior=convertTo
    Null

    it might help to read this first if you're having trouble connecting with MySQL

    [url]http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=6ef0253[/url]



    DROdio. Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139