Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date/Time Help

Status
Not open for further replies.

danarashad

Programmer
Nov 2, 2006
115
US
<CFSET form.timestamp=Now()>

INSERT INTO commonLinks(title,description,url,timestamp)
VALUES('#form.title#','#form.description#','#form.url#',#dateformat(form.timestamp,"m/dd/yyyy")# #timeFormat(form.timestamp,"h:mm:ss tt")#)

I am trying to insert a timestamp into my database but I keep getting this error.
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
SQL = "INSERT INTO commonLinks(title,description,url,timestamp) VALUES('fdsafadfsdfasdf','fdfasdfsdfsd',' 09:29:35 AM)"
I am trying to enter the date as 7/26/2007 09:29:35 AM
 
If "TimeStamp" is a date/time column, use cfqueryparam to insert the current date and time. An alternative is to set the "Default Value" in Access to now(). So whenever a record is added the "Timestamp" value will automatically be set to the current date and time. This means you would not need to include the timestamp column in your insert.

You should also watch out for reserved words. I think "TimeStamp" is a reserved word in Access. I don't know about "URL". Either rename the "TimeStamp" column or use [] to escape the column name

Code:
INSERT INTO commonLinks(title,description,[url],[timestamp])
VALUES(
'#form.title#',
'#form.description#',
'#form.url#',
<cfqueryparam value="#now()#" cfsqltype="cf_sql_timestamp">
)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top