Friday, February 17, 2012

Debug with datetime datatype

Hi,
When I debug a stored procedure, if one of the input parameters is
datetime datatype, it doesn't matter what I type in, i got an error said
"Invalid character value for cast specification" Any idea what value I need
to key in?
example
create procedure ztest
@.Input smalldatetime
as
If @.input = '5/1/2005'
print 'Good'
Else
print 'Bad'
in debug mode, i key in '5/1/2005' for @.Input, but error occurs.
Thanks
EdI believe that one of below formats will work:
{ ts '1998-05-02 01:23:56.123' }
{ d '1990-10-02' }
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Ed" <Ed@.discussions.microsoft.com> wrote in message
news:62386CA6-E369-4D53-9BB6-13A80A175E53@.microsoft.com...
> Hi,
> When I debug a stored procedure, if one of the input parameters is
> datetime datatype, it doesn't matter what I type in, i got an error said
> "Invalid character value for cast specification" Any idea what value I ne
ed
> to key in?
> example
> create procedure ztest
> @.Input smalldatetime
> as
> If @.input = '5/1/2005'
> print 'Good'
> Else
> print 'Bad'
> in debug mode, i key in '5/1/2005' for @.Input, but error occurs.
> Thanks
> Ed
>|||Ed,
It's not you. The debugger data entry for datetime is buggy. ;)
Use the format
YYYY-MM-DD HH:MM:00.000, or for your date
2005-05-01 00:00:00.000
Put all the zeros in, even though you just have a smalldatetime (even if
you had datetime, you need to make them zero, because the debugger
doesn't handle more precision).
Here are a couple of old newsgroup threads on this bug:
http://groups-beta.google.com/group...ldatetime&hl=en
Steve Kass
Drew University
Ed wrote:

>Hi,
> When I debug a stored procedure, if one of the input parameters is
>datetime datatype, it doesn't matter what I type in, i got an error said
>"Invalid character value for cast specification" Any idea what value I nee
d
>to key in?
>example
>create procedure ztest
> @.Input smalldatetime
>as
>If @.input = '5/1/2005'
> print 'Good'
>Else
> print 'Bad'
>in debug mode, i key in '5/1/2005' for @.Input, but error occurs.
>Thanks
>Ed
>
>

No comments:

Post a Comment