Passing Date and Time into Mysql

Discussion in 'Programming' started by Joe K, May 4, 2007.

  1. #1
    I'm trying to pass the current date and time from a validation page into a mysql table. I've tried numerous methods, but keep getting the same issue. Here is the most recent attempt:

    <cfset cdate = CreateODBCDateTime (Now())>

    "CFQuery Tags

    insert into XTable (fname, lname, cdate) values('#fname#', '#lname#', '#cdate#')

    "Close CFQuery

    The mysql db column is set up as follows:

    Field=cdate Type=DATETIME Null=not null Default2= 0000-00-00 00:00:00

    Any thoughts?
     
    Joe K, May 4, 2007 IP
  2. IsRoss()

    IsRoss() Peon

    Messages:
    116
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have you tried inserting #Now()# with no quotes, no createodbcdatetime...?

    insert into XTable (fname, lname, cdate) values('#fname#', '#lname#', #Now()#)
     
    IsRoss(), May 4, 2007 IP
  3. Aztral

    Aztral Well-Known Member

    Messages:
    344
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    125
    #3
    Or create the default value for your date field as CUR_DATE() then
    insert into XTable (fname, lname, cdate) values('#fname#', '#lname#', DEFAULT)

    ??
     
    Aztral, May 16, 2007 IP