Date insertion problems MySQL

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

  1. #1

    Default Date insertion problems MySQL

    I am currently trying to update a mysql database with a date entered using a
    form. However when I look at the database the date always reads 1/1/0001.

    I tried locally with debugging on and the date is getting submitted as fom
    data. Look like this 03/09/2005


    Here is my code:

    <cfquery datasource="dumped">
    UPDATE dumped SET dumpdate=
    <cfif IsDefined("FORM.dumpdate") AND #FORM.dumpdate# NEQ "">
    #FORM.dumpdate#
    <cfelse>
    NULL
    </cfif>

    Any help would be great!

    Buddhatech74 Guest

  2. Similar Questions and Discussions

    1. Mysql Date Problem
      Hi, I am trying to get the date from a MYSQL server into a PHP page I am creating with Dreamweaver, I create a new recordset and go to advanced and...
    2. CFMX blob insertion to MySQL
      I am trying to use CFMX to store a binary (blob) into a MySQL db. Using MySQL Control Center (GUI interface to the db), I have manually placed a...
    3. PHP Date into MySQL
      Hi, I have the following script that is installed to obtain the date 7 days into the future and display 1 weeks worth of dates (minus Sunday). I...
    4. date mysql
      Hi I have troubles with converting a date value to unixtime! In mysql I have a table named date TYPE "DATE" (2003-09-05) Now I want it to convert...
    5. DATE insertion
      Hi all, First of all, thanks to everyone who helped me with the "checkbox" issue. I have an issue here while trying to INSERT INTO a MySQL table...
  3. #2

    Default Re: Date insertion problems MySQL

    Budd, Check out the function CreateODBCDateTime(). It may help you here.
    Also, if FORM.dumpdate is in the format mm/dd/yyyy or dd/mm/yyyy, surround it
    with single quote marks (or, for Access, the dreaded pound sign). HTH,

    philh Guest

  4. #3

    Default Re: Date insertion problems MySQL

    Ok So I took some of your suggestions and I think I am closer. Thank you. Here
    is my code now:

    <cfquery datasource="dumped">
    UPDATE dumped SET dumpdate=
    <cfif IsDefined("FORM.dumpdate") AND '#FORM.dumpdate#' NEQ "">
    #DateFormat(CreateODBCDate(FORM.dumpdate), "dd/mm/yyyy")#

    <cfelse>
    NULL
    </cfif>

    and here is whats being submitted:

    SQL Queries

    (Datasource=dumped, Time=0ms, Records=0) in
    C:\Inetpub\wwwroot\dumped\dumpeeinfo.cfm @ 14:02:24.024

    UPDATE dumped SET dumpdate=

    22/03/2005


    , besttime=

    NULL

    , customermessage=

    NULL

    Keep in mind the date is coming from one field in my form.

    Thanks for any help I can get.



    Buddhatech74 Guest

  5. #4

    Default Re: Date insertion problems MySQL

    Yup, almost there. <cfquery datasource='dumped'> UPDATE dumped SET dumpdate=
    <cfif IsDefined('FORM.dumpdate') AND '#FORM.dumpdate#' NEQ ''>
    #DateFormat(CreateODBCDate(FORM.dumpdate), 'dd/mm/yyyy')# <cfelse> NULL
    </cfif> Now, surround the date value with single quotes: <cfquery
    datasource='dumped'> UPDATE dumped SET dumpdate= <cfif
    IsDefined('FORM.dumpdate') AND '#FORM.dumpdate#' NEQ ''>
    '#DateFormat(CreateODBCDate(FORM.dumpdate), 'dd/mm/yyyy')#' <cfelse> NULL
    </cfif> I don't know what your flavor of DB accepts for date delimiters, so
    YMMV. HTH,

    philh 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