• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 880
  • Last Modified:

Entering datetime data into Sql Query Analyzer debug dialog

I am trying to enter a datetime into a stored procedure thru the SQL Query Analyzer Debug Dialog such as 2003-02-01 12:00:00 AM.
When i hit the execute button, i get the following error...
Invalid character value for cast specification

How do i enter datetime values into the Sql Query Analyzer debug window

Thanks

0
eddyevations
Asked:
eddyevations
  • 5
  • 3
  • 2
  • +1
1 Solution
 
KarinLoosCommented:
insert tableA values ( '2003-02-01 12:00:00 AM')  
thus make it a string
0
 
eddyevationsAuthor Commented:
i am debugging a stored procedure from Sql Query Analyzer...right click on the stored procedure and then select "debug..." from the context sensitive menu...then a dialog will appear which allows you to enter the parameters for the proc...I have had success entering dates alone but when i enter dates and times, it does not work.
0
 
KarinLoosCommented:
ok in that case dont make a string and leave off the AM or PM part (ie use 24 hour clock) then it will work
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
eddyevationsAuthor Commented:
I tried "2004-12-23 14:30" and it did not work
0
 
Anthony PerkinsCommented:
Do not use double quotes or single quotes for that matter.  If this is not it than post your stored procedure.

Also, please elaborate on what "did not work".  This is singularly unhelpful. Tell us either:

1. It gave the same error message.
2. It gave another error message, if so what is it.
3. It gave the wrong results, if so what did you get and what was desired.
4. Smoke came out of your monitor.
0
 
eddyevationsAuthor Commented:
I did not use any quotes.  I am using quotes here to "quote" my input.  

So...
i entered the following...

2004-12-23 14:30

and it gave me the following error...

[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification
0
 
Anthony PerkinsCommented:
Since I was unable to duplicate the problem, I can only assume that the problem lies in the stored procedure (for example you are using smalldatetime instead of datetime), but since you have not posted it, I really cannot help you any further...
0
 
illCommented:
-- personally, i hate datetime , especially when inserting from web browser. this one works often for me, but...
dec 23 2004 14:30  

0
 
eddyevationsAuthor Commented:
Thanks ill,
But that did not work for me.  I can enter 2004-11-23.  But when i add the time component, id does not like it.  I get the error
[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification

My Stored Proc is...
CREATE  proc PrivProcGetStateDataValueBeforeDate
(
      @date datetime
)
as begin
0
 
Anthony PerkinsCommented:
That is because you are not including the seconds.  Use:
2004-12-23 14:30:00
0
 
eddyevationsAuthor Commented:
Thanks acperkins,
That was simple :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now