Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Inserting a smalldatetime from an ASP VBScript page

Posted on 2006-11-22
11
Medium Priority
?
1,239 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 2000 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

721 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