Click to See Complete Forum and Search --> : Adding today's date to a record
NatuScape
02-21-2003, 11:00 AM
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
Ribeyed
02-21-2003, 01:44 PM
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, :D
NatuScape
02-21-2003, 01:51 PM
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
Ribeyed
02-21-2003, 02:08 PM
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:
','::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
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:
#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
NatuScape
02-24-2003, 06:57 AM
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
Ribeyed
02-24-2003, 07:23 AM
hi,
good stuff, well done:D