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

x
?
Solved

Error when convert string to timestamp

Posted on 1999-10-22
4
Medium Priority
?
330 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
[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 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

[Webinar] Protection from Cyberattacks

In this session, we’ll dive into the complexities of modern cyber threats and why only multi-vector protection can keep today’s businesses secure through the various stages of a cyberattack, across multiple vectors. Thursday September 14, 2017 10:00 A.M. PDT

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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

730 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