?
Solved

Error when convert string to timestamp

Posted on 1999-10-22
4
Medium Priority
?
334 Views
Last Modified: 2013-12-25
Hi,

I need to input a SQL_TIMESTAMP parameter to a stored procedure of a SQL
server,
so I use SQLBINDPARAMETER to convert SQL_C_CHAR to SQL_TIMESTAMP and then
call SQLEXECUTEDIRECT.
e.g.  input "1999-10-10 10:34:24" and convert to TIMESTAMP format by using
SQLBINDPARAMETER
but SQL driver return "invalid character of casting specification" error
messages.

Anyone know how to solve it??
Is it possible to input a character string as timestamp??

Thanks
C8X
0
Comment
Question by:C8X
4 Comments
 
LVL 4

Expert Comment

by:agarwal_rahul
ID: 2154256
I am not sure if I have understood u r question correctly....but looks like u want to accept value for timestamp in the sp. If yes then I think u can get character string and convert it using

select convert(timestamp,getdate()). This works in SQL Server 7.0....

But I don't understand why u want to get timestamp value from the user
0
 

Author Comment

by:C8X
ID: 2156362
I need to input a timestamp value to a Stored Procedure in MSSQL for execution.
The input will be a string of format "yyyy-mm-dd hh:mm:ss.ffffff". But it seems that the SQL driver can't convert it correctly automatically. So I am now do convertion myself to SQL_TIMESTAMP first though I think it's not good.
0
 
LVL 7

Expert Comment

by:simonsabin
ID: 2160279
What is the parameter definition of the SP?

What is the code you are using?


0
 
LVL 1

Accepted Solution

by:
mathies earned 100 total points
ID: 2164368
Your problem his in your date format.

In database, you always need to enter date in English format.  "mm/dd/yyyy"
and this value should be sent between single quote.
if i look what you have
1999-10-10 10:34:24

you forget quote, date his in invalid format and your forget the miliseconds

The format his that one.
'mm/dd/yyyy hh:mm:ss:fff'

0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

594 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