Solved

Inserting a smalldatetime from an ASP VBScript page

Posted on 2006-11-22
11
1,162 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 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
 
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 26

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 26

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 26

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now