Adding today's date to a record
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?????
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 01:49 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???
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:
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
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:
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 02:11 PM.
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...!
good stuff, well done
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)