Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2006
    Posts
    72

    Unanswered: Inserting date into a column - error

    Hello

    I am using the following to insert some form field names into an MS Access 2000 database:

    SQL="INSERT INTO users (name, email, business, country, message, date) VALUES ('" & _
    name & "', '" & email & "','" & business & "', '" & country & "', '" & message & "', #" & Date() & "#)"


    It did work fine until I tried to insert the date (the first column in my database), but now I am getting the following error:

    http://stevehigham59.7host.com/trial/flash.asp

    I have tried inserting a " and then removing the single ' but can't seem to get it to work.

    Any help appreciated.

    Steve

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Hey again Steve

    Have you tried using literal text?
    Code:
    INSERT INTO user(name, date)
    VALUES ('georgev', #31/12/2008#)
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2006
    Posts
    72
    Hello George

    Nice to hear from you again. I see you are still very much active here!!

    On the form itself there is no place for the site visitor to input a date, but I thought the script would insert it without it being typed in to a particular field.

    That is, the date is the 'current date', the date the individual visits the site and sends the form. I do not mind what format it is in, but prefer not to have the 12/28/08 format as I have to try to read backwards, if you know what I mean.

    Thanks for your post.

    Steve

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Steve, try the hard-coded version as above.

    Also, can you confirm that the field you've called "date" is of a datetime datatype?

    And if I were you I'd rename the column too; date is one of those funny words that the SQL engine kinda likes
    George
    Home | Blog

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Oh, and your other option is to set the default value of the field within your database... Then you don;t even have to bother with it in your isnert statement
    George
    Home | Blog

  6. #6
    Join Date
    Feb 2006
    Posts
    72
    Well that makes things a lot easier!!

    Many thanks, George.

    Best regards

    Steve

Posting Permissions

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