inserting date into MySql Database

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

  1. #1

    Default inserting date into MySql Database

    I am trying to insert the current date into a MySql database. I know that the
    date format for MySql is yyyy-mm-dd . So far I have tried to insert it like
    this:
    <cfquery datasource="xxx" username="xxx" password="xxx">
    INSERT INTO Time (Time)
    VALUES ('#CreateODBCDate(yyyy,mm,dd)#' )
    </cfquery>
    The error I get is that the function takes one parameter.
    Any help someone could offer would be much apreciated.


    khotwheels Guest

  2. Similar Questions and Discussions

    1. Best Method to insert a Date into a MySQL database?
      Dear all, I would like to know which is the best method to insert date into a field in a table of a MySQL database and be able in the future to...
    2. Trouble inserting date into database
      The date format in the form being submitted is mm/dd/yyyy. Below is the error I'm getting. Any help would make me really happy! Thanks Error...
    3. Inserting Current Date into MySQL Database
      OK, I am a complete Newbie at this, well... almost... I am creating a database that accepts members. I need to know how to insert the date of...
    4. inserting the current date into mysql database fild
      Hi I'm using DW MX and the php_mysql server model I have generated this code for inserting data into the DB. <code> if...
    5. inserting date
      Use the Date function. In your query, it would be something like SELECT Field1, Field2, Date() FROM MyTable For the text box, you'd set its...
  3. #2

    Default Re: inserting date into MySql Database

    #CreateODBCDate("#NOW()#")#

    It takes an existing date and makes a properly formatted date for an ODBC
    compliant database, so long as you are inserting it into an actual date field
    in the DB it should work



    SafariTECH Guest

  4. #3

    Default Re: inserting date into MySql Database

    I am trying to insert the date (yyyy-mm-dd) not time. I should have named the
    field differently. I did try your suggestion and it gave me the following
    error.
    Error Executing Database Query - Syntax error or access violation: You have
    an error in your SQL syntax; check the manual that corresponds to your MySQL
    server version for the right syntax to use near '2005-09-01'}')' at line 3
    I thought perhaps I should take out the hash symbols surrounding the NOW
    function but it gave me the same error.

    khotwheels Guest

  5. #4

    Default Re: inserting date into MySql Database

    I took the quotes out around the hash symbols and it worked. Thank you very much for your help.
    khotwheels 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