Inserting a smalldatetime from an ASP VBScript page

Hi experts,

I am having a very frustrating time trying to convert the current date to smalldatetime to insert into our database. I have tried every damned VBScript date conversion function I know of, and every damned SQL date conversion function that I know of. All I want is the current date inserted into the row!
Tabris42Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MrNeticCommented:
Tabris42 ,

Why don't you use the getdate() function on the column that contains the date.

And with this you don't have to worry about how to insert the date on the system.

Best Regards,

Paulo Condeça
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tabris42Author Commented:
How would I use it? I've tried this:

INSERT INTO tblsupport_news VALUES ('Feature',25901,25900, getdate())

INSERT INTO tblsupport_news VALUES ('Feature',25901,25900, CONVERT(smalldatetime, getdate(), 102))

Always the same error: Operand type clash: int is incompatible with ntext
This is so frustrating. Microsoft once again manages to take the simple and mundane and make it a nightmare.
0
MrNeticCommented:
Tabris,

Acording to you error, it is a conversion problem, you are trying to insert an int in a ntext column...

And you configure the getdaet() in SQL Server, not in the statement ( Default Value for column getdate())

Best Regards,

Paulo Condeça
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

azserrataCommented:
Hi Tabris

Fore sure the error is not in the date field.

My guess is that the field(s) where you're trying to insert 25901, 25900 are NTEXT and not numeric.

About the getdate() you don't need to convert it, use directy as in your FIRST INSERT statement.

Cheers
David
0
ZberteocCommented:
If you set as default value for the smalldatetime field the getdate() function, you don't have to worry about it in the insert statement. Insert only the rest of the fields but make sure that the fields' types match the values' types used in the insert statement.
0
azserrataCommented:
Using a default value for a field is used whenever we want to insert something EVERY time a record is inserted. If this is the case, go for it. But that is not said in the question. In fact, the error doesn't seem related a date conversion but to a INT <-> NTEXT convertion.

Sorry guys but I think we should try to avoid dispertion and stick as much as we can to the problems stated.

Cheers
azserrata
0
ZberteocCommented:
azserrata,

The only desperation I noticed was in your last post. Let's do this; you stick to your answers and everyone else with theirs and let the author choose the right one.

I suggest Tabris to copy the exact statement and the exact error message an paste it here. In the examples you gave the column list is missing, for instance, but giving the error that can't be the problem.
0
azserrataCommented:
Zberteoc

Sorry, I guess my english is not good enough (I know it isn't). Want I meant was not desperation (no one seems desperate), I meant diversion ... and I wrote dispertion.

As of Tabris to copy the exact statement and exact error message I guess he already did that ... way back.

azserrata


0
ZberteocCommented:
Point is this website is a place of learning and sharing ideas for everyone, asking and answering as well. There are plenty other websites for playing the smart guy.

I hope my english was clear enough.

Zberteoc out.
0
azserrataCommented:
Sure your english was clear enough. When I said mine is not good enough I meant EXACTLY that, as my native language is portuguese. That was no irony at all.

I'm not sure to what do you mean with "play smart guy" but on how this stupid discussion started,  I believe the thread speeks for it self.

I'm out of it.

cheers
azserrata
0
Tabris42Author Commented:
Oh wow what's happened here.. ?

Yes this did indeed turn out to be an int/ntext conversion problem. Smacked my forehead over that one, I had made the table change on my dev server but not my production server. The getDate() function in SQL is very handy as well.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.