Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Inserting a smalldatetime from an ASP VBScript page

Posted on 2006-11-22
11
Medium Priority
?
1,254 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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

782 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