DateTime Value 0000:00:00 in MySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alcstudio
    New Member
    • Sep 2007
    • 24

    DateTime Value 0000:00:00 in MySQL

    Hey there. I have a problem whit some date insert.

    I Have 3 dropdownlists and i want the code to get the values and insert them in the database,

    the code looks like this:

    yyyy = Request.Form("y yyy")
    mm = Request.Form("m m")
    dd = Request.Form("d d")
    strborn = DateSerial(yyyy ,mm,dd)

    Its insert everything but not the date. only get 0000:00:00.

    the Datatype is set to DATETIME and its NULL

    Go crazy,, need help =)
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    The date format in MySQL is YYYY-MM-DD.
    Are you sure you have your 'date-to-be-inserted' in that format?
    Otherwise show some of the code.

    Ronald

    Comment

    • alcstudio
      New Member
      • Sep 2007
      • 24

      #3
      "date-to-be-inserted" Hmm dont understand =). I know that the date format is YYYY-MM-DD.

      What code do you want to see ? The insert code? If it so here it is:

      Code:
      objconn.execute("INSERT into konton (anvnamn, losen, epost, fornamn, efternamn, personnf, personns, hur, reggad, kon) Values ('"&request.form("anv")&"', '"&request.form("losen")&"', '"&request.form("epost")&"', '"&request.form("fornamn")&"', '"&request.form("efternamn")&"', "&[B]strborn[/B]&", '"&request.form("perns")&"', '"&request.form("Hur")&"', CURRENT_TIMESTAMP(), '"&request.form("kon")&"')")

      Comment

      • mwasif
        Recognized Expert Contributor
        • Jul 2006
        • 802

        #4
        use single quotes around the value
        Code:
        objconn.execute("INSERT into konton (anvnamn, losen, epost, fornamn, efternamn, personnf, personns, hur, reggad, kon) Values ('"&request.form("anv")&"', '"&request.form("losen")&"', '"&request.form("epost")&"', '"&request.form("fornamn")&"', '"&request.form("efternamn")&"', '"&strborn&"', '"&request.form("perns")&"', '"&request.form("Hur")&"', CURRENT_TIMESTAMP(), '"&request.form("kon")&"')")

        Comment

        • alcstudio
          New Member
          • Sep 2007
          • 24

          #5
          When i do so i get:

          [MySQL][ODBC 3.51 Driver][mysqld-5.0.51a-community-nt]Incorrect datetime value: '1/1/1960' for column 'personnf' at row 1

          You can see that the date is in wrong order but in the code right.

          How do i fix this? if i fix it in right order do you think it will work.

          Comment

          • alcstudio
            New Member
            • Sep 2007
            • 24

            #6
            Please guys really need help with this.. This is the last thing thats not working.

            Comment

            • alcstudio
              New Member
              • Sep 2007
              • 24

              #7
              I did get it to work with this:

              strborn = ""&request.form ("yyyy")&"-"&request.form( "mm")&"-"&request.form( "dd")&""

              Comment

              • ronverdonk
                Recognized Expert Specialist
                • Jul 2006
                • 4259

                #8
                Thanks for sharing your solution with our members.
                See you next time.

                Ronald

                Comment

                Working...