Solved

Inserting a smalldatetime from an ASP VBScript page

Posted on 2006-11-22
11
1,220 Views
Last Modified: 2008-01-09
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!
0
Comment
Question by:Tabris42
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 5

Accepted Solution

by:
MrNetic earned 500 total points
ID: 17995703
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
 

Author Comment

by:Tabris42
ID: 17995796
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
 
LVL 5

Expert Comment

by:MrNetic
ID: 17995855
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
Webinar: MongoDB® Index Types

Join Percona’s Senior Technical Services Engineer, Adamo Tonete as he presents “MongoDB Index Types, How, When and Where Should They be Used?” on Wednesday, July 12, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7).

 
LVL 3

Expert Comment

by:azserrata
ID: 17996316
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
 
LVL 27

Expert Comment

by:Zberteoc
ID: 17998425
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
 
LVL 3

Expert Comment

by:azserrata
ID: 17999350
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
 
LVL 27

Expert Comment

by:Zberteoc
ID: 17999716
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
 
LVL 3

Expert Comment

by:azserrata
ID: 18000006
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
 
LVL 27

Expert Comment

by:Zberteoc
ID: 18001076
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
 
LVL 3

Expert Comment

by:azserrata
ID: 18002634
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
 

Author Comment

by:Tabris42
ID: 18007514
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question