SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    minister of propaganda silver trophy Rynoguill's Avatar
    Join Date
    Feb 2004
    Location
    Midsouth
    Posts
    1,373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql date question

    can someone tell me the correct way to input a date field in mysql? it may be my cf, but it seems like it works differently every stinkin time.

    i have three fields in the table, id(int, pk, autoincrement), itemnum(int), and expirationdate(date),
    here is my code:
    Code:
    <cfquery name="InsertRecord" Datasource="#Variables.Datasource#">
    						INSERT INTO #Variables.TableName# (ItemNum, ExpirationDate)
    						VALUES (#Arguments.ItemNum#, #CreateODBCDate(Arguments.ExpirationDate)#
    					</cfquery>
    and heres the error i get:
    Code:
     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 '' at line 2
     
    The error occurred in C:\Inetpub\wwwroot\cb\www\Manage\cfcs\NewReleases.cfc: line 79
    Called from C:\Inetpub\wwwroot\cb\www\Manage\products\newreleases.cfm: line 13
    Called from C:\Inetpub\wwwroot\cb\www\Manage\cfcs\NewReleases.cfc: line 79
    Called from C:\Inetpub\wwwroot\cb\www\Manage\products\newreleases.cfm: line 13
    
    77 : 					<cfquery name="InsertRecord" Datasource="#Variables.Datasource#">
    78 : 						INSERT INTO #Variables.TableName# (ItemNum, ExpirationDate)
    79 : 						VALUES (#Arguments.ItemNum#, #CreateODBCDate(Arguments.ExpirationDate)#
    80 : 					</cfquery>
    81 : 				<!--- <cfcatch type="any">
    
    SQL 	   INSERT INTO NewReleases (ItemNum, ExpirationDate) VALUES (5599, {d '2008-01-01'}
    DATASOURCE 
    VENDORERRORCODE 	  1064
    SQLSTATE 	  42000
    any help at all will be greatly appreciated. and for the record i tried it with single quotes around the date field and it bombs there too.
    rynoguill
    Ryan Guill, AKA Mark Roman

  2. #2
    minister of propaganda silver trophy Rynoguill's Avatar
    Join Date
    Feb 2004
    Location
    Midsouth
    Posts
    1,373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nevermind, it would help if i closed my last parenthesis.

    im sorry, ive been doing this a lot lately, ill try to look at my stuff more before i post a question.

    but just so everyone knows, as far as using cf, just createodbcdate() and insert without single quotes.

    thanks guys
    rynoguill
    Ryan Guill, AKA Mark Roman


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •