Print Page | Close Window

Stactic String Parameters parsed into date error

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=14099
Printed Date: 07 May 2024 at 9:14am


Topic: Stactic String Parameters parsed into date error
Posted By: robtyketto
Subject: Stactic String Parameters parsed into date error
Date Posted: 16 Aug 2011 at 2:02pm
Greetings,
 
My crystal reports datasource is a stored proc (SQL server 2005) that expects 2 parameters:
@startDate varchar,
@endDate varchar
 
These are converted to a datetime in the stored proc as follows:
W.WeekEnd >= Convert(datetime, @startDate, 20)
 
When I set the stored proc as the datasource it prompts for values for both fields which I enter as follows:
2011-08-01 00:00:00
2011-08-17 00:00:00
 
This results in the error
Conversion failed when converting datetime from character string.
 
In t-sql if I run the exact same command in the stored proc it runs and returns a date e.g.
 
Select Convert(datetime, '2011-08-01 00:00:00', 20) as RobsTime
2011-08-01 00:00:00.000
 
Hope someone can advise me of why the error is occuring, I'm baffled.
 


-------------
Thanks
Rob



Replies:
Posted By: lockwelle
Date Posted: 17 Aug 2011 at 2:30am
run a trace (profiler) on what CR is sending to your proc.  Once you have the parameters, you can then work to modify the proc to perform correctly.
 
Running the proc with the parameter information will also give a line number of where the error is...it might be somewhere you didn't expect
 
HTH


Posted By: robtyketto
Date Posted: 18 Aug 2011 at 3:39am
Originally posted by lockwelle

run a trace (profiler) on what CR is sending to your proc.  Once you have the parameters, you can then work to modify the proc to perform correctly.
 
Running the proc with the parameter information will also give a line number of where the error is...it might be somewhere you didn't expect
 
HTH


Thanks for the advice I ran the SQl profiler and the value was passed in as expected.

I didn't fully test the store procedure and the issue was a t-sql issue when I declared the varchar variable as I didn't specify the length.

Thanks Smile


-------------
Thanks
Rob



Print Page | Close Window