SQL Date problem

Discussion in 'MySQL' started by J.P, Oct 14, 2005.

  1. #1
    Hi all I have a problem and hope someone here could help.

    I have a page where you add reviews to specific bars etc.

    On the form page I have the date as - DateFormat(now(), "yyyy/mm/dd")

    I'm passing the date to the insert page and the code to insert into MySQL is - '#dateformat(adddate,"yyyy/dd/mm")#'

    The MySQL DB, the field is called adddate, the type is date and nothing else is filled in.

    It was working the other day but today when a comment is added the adddate is set to 0000-00-00

    Anyone got any ideas?

    JP
     
    J.P, Oct 14, 2005 IP
  2. Perrow

    Perrow Well-Known Member

    Messages:
    1,306
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    140
    #2
    try printing the variable just prior to building the sql statement. If that looks ok, then print the built sql statement instead of running it. If you can't spot the problems there, post the sql here and we'll look at it.
     
    Perrow, Oct 14, 2005 IP
  3. J.P

    J.P Notable Member

    Messages:
    767
    Likes Received:
    42
    Best Answers:
    3
    Trophy Points:
    205
    #3
    The page before will print out the date with no problem, the insert page aint showing it.

    I'm at a loss, yesterday this was working fine, today nothing. I've sent my host a e-mail to see if they changed something as I've not changed a thing (apart from this afternoon trying to fix it) :(
     
    J.P, Oct 14, 2005 IP
  4. J.P

    J.P Notable Member

    Messages:
    767
    Likes Received:
    42
    Best Answers:
    3
    Trophy Points:
    205
    #4
    Right, host has changed nothing yesterday but today that un-changed code is not working...

    So if anyone is willing to help.

    Programming is in Coldfusion but it runs SQL stylie :)

    code before the SQL insert.

    <cfset today = DateFormat(now(), "yyyy/mm/dd")>

    <tr>
    <td class="tabletext"><cfoutput><input type="text" name="adddate" readonly="readonly" value="#today#" size="20"></cfoutput></td>
    </tr>

    (part of the forum)

    The insert page;

    <cfquery datasource="puerto_info" username="#application.dsnusername#" password="#application.dsnpassword#" name="insert_comment">
    INSERT INTO comments (adddate,firstname,lastname,email,comment,barid,rating)
    VALUES ('#dateformat(adddate,"yyyy/dd/mm")#','#firstname#','#lastname#','#email#','#comment#','#barid#','#rating#')
    </CFQUERY>

    So.. the problem I seem to have is in the SQL DB, after a person submits a comment/rating the date is being inserted as 0000-00-00

    So any thoughts?
     
    J.P, Oct 14, 2005 IP
  5. J.P

    J.P Notable Member

    Messages:
    767
    Likes Received:
    42
    Best Answers:
    3
    Trophy Points:
    205
    #5
    no matter.. it seemed to be the date format causing the problem.. why. who knows! :)
     
    J.P, Oct 14, 2005 IP
  6. king_cobra

    king_cobra Peon

    Messages:
    373
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #6
    u shd be entering the date as yyyy-mm-dd and not yyyy/mm/dd.
     
    king_cobra, Oct 14, 2005 IP