|
-
Aug 30th, 2002, 06:05 AM
#1
Thread Starter
Fanatic Member
crystal reports datetime problem (resolved)
i've got a crystal report that feeds off a stored procedure, that requires a datetime parameter. but when i pass a date in to the report from VB, i get a type mismatch error. this is the code i have to pass the date in:
VB Code:
pReport.ParameterFields(i).AddCurrentValue CDate(strParams(i - 1)) 'strParams(i - 1) is "01/01/01"
i thought this might be because crystal wants a time as well, so i tried this:
VB Code:
pReport.ParameterFields(i).AddCurrentValue Format(strParams(i - 1), "dd/mm/yy hh:mm:ss")
which still didn't work. then i tried just using the Now() function, and didn't get an error (although the report obviously returned no results).
has anyone overcome this problem?
Last edited by tr0n; Aug 30th, 2002 at 07:07 AM.
-
Aug 30th, 2002, 06:16 AM
#2
Frenzied Member
The format seems right;
Did you try to fetch the result of
Format(strParams(i - 1), "dd/mm/yy hh:mm:ss")
could be it isn't what you needed.
Code:
If Question = Incomplete Then
AnswerNextOne
Else
ReplyIfKnown
End If
cu Swatty
-
Aug 30th, 2002, 06:20 AM
#3
Thread Starter
Fanatic Member
yup, Format(strParams(i - 1), "dd/mm/yy hh:mm:ss") returned "01/01/01 00:00:00".
-
Aug 30th, 2002, 06:26 AM
#4
^:^...ANGEL...^:^
Hmm...
how about changing it to text I mean CStr function...
give it a go and I hope it should work...
-
Aug 30th, 2002, 06:31 AM
#5
Thread Starter
Fanatic Member
nope i've even tried using CVar().
for every other data type i'm passing to a report, i'm using CLng for numbers, CStr for strings, CDate for dates, etc., but for some reason it doesn't wanna know when it comes to a DateTime.
-
Aug 30th, 2002, 06:53 AM
#6
Thread Starter
Fanatic Member
ah, i think i found a solution. i just went to File -> Report Options and chose "Convert Date-Time Field: To Date".
-
Aug 30th, 2002, 07:09 AM
#7
Frenzied Member
Code:
If Question = Incomplete Then
AnswerNextOne
Else
ReplyIfKnown
End If
cu Swatty
-
Aug 30th, 2002, 07:26 AM
#8
Thread Starter
Fanatic Member
yep
-
Aug 30th, 2002, 07:49 AM
#9
Addicted Member
U found it
That was a good solution. I had the same problem too.
But the only problem may be if you want to display a date with time. In that case you can try the below code.
I went to my stored procedure and changed my date parameter to char(11) and converted that parameter to date inside sto proc. This works.
Any comments or suggestions?
Last edited by vsusi; Aug 30th, 2002 at 07:55 AM.
-
Aug 30th, 2002, 07:58 AM
#10
Thread Starter
Fanatic Member
yeah, that seems like a pretty good solution too, if you need to have both date and time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|