www.webdeveloper.com
Results 1 to 6 of 6

Thread: Adding today's date to a record

  1. #1
    Join Date
    Nov 2002
    Location
    Norwood, MA
    Posts
    187

    Question Adding today's date to a record

    Hello!!

    I am trying the simplest thing, and for some reason my fingers can't seem to type in the right coding... I want to insert a record into a database and use today's date in one of the fields. Here's my code:

    fp_sQry="INSERT INTO Results (Key,Initiator,Description,Date) VALUES ('" & keykey & "','::Initiator::','::Description::',#" & Date() & "#)"

    It ain't workin'...... Any ideas?????

    Thanks!!!!!!

    Natalia

  2. #2
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    hi,
    are you getting a data type miss match error?
    Is the Database field a Date or text type field?

    And can i suggest that you try getting Dreamweaver and code your ASP yourself, this front page stuff sucks,
    Last edited by Ribeyed; 02-21-2003 at 02:49 PM.

  3. #3
    Join Date
    Nov 2002
    Location
    Norwood, MA
    Posts
    187
    Ribeyed: how about offering some help instead of critizing the tools I use? Not everyone can afford Dreamweaver, but that's not the point of my posting.

    Is there anything actually wrong with the bit of code I posted? Aren't the # symbols supposed to enforce the entry of a date format???

    Thanks!

    Natalia

  4. #4
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    hi,
    at first look there doesn't seem to be a syntax error in your code, but saying that the code that frontpage generates for ASP is diiferent. I wouldn't be able to tell you if this part of your SQL is correct:
    Code:
    ','::Initiator::','::Description::'
    I would love to help you further but i need to know what error was generated, did you get an data type miss match error?
    If your database field is of text type then your syntax is wrong, but if it is date/time type then i would write the SQL statement out to screen to check what values are being submitted.
    Just comment out all the working for the SQL after the statment and your execute line. Put in the following

    Code:
    response.write fp_sQry
    now you should see the sql query on the screen.
    Your date should be displayed. Now you are looking to see if your date is being displayed like one of the following:

    Code:
    #12/12/2001#
    or
    '12/12/2001'
    or 
    12/12/2001
    so depending on your field in your database one of these will be correct. Also forgot to ask is it Access or SQl Server or another database you are using, again this will effect the syntax
    Last edited by Ribeyed; 02-21-2003 at 03:11 PM.

  5. #5
    Join Date
    Nov 2002
    Location
    Norwood, MA
    Posts
    187
    Hey Dave and Ribeyed,

    Putting together a bit of what both of you suggested and a bit of my own wit, I got it working!! What was wrong in the first place was that I used "Date" for my field's name, and that's a big NO-NO!!!!! How come neither of you detected that? Well, I should have known better... Anyway, changing the field name to CorrActDate and using Dave's format date thing (thanks, I needed that for another page) and Ribeyed's suggestion to spell out the query, and I got it!!!!!

    Thanks to both, and remember: it's not the power of the tools themselves that make the work extraordinary, but the art of the user!!! Michelangelo could have chiseled out the David with a soup spoon, it just would have taken him longer, that's all!!

    You can quote me on that...!

    Natalia

  6. #6
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    hi,
    good stuff, well done

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles