Results 1 to 10 of 10

Thread: crystal reports datetime problem (resolved)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638

    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:
    1. 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:
    1. 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.

  2. #2
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478
    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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    yup, Format(strParams(i - 1), "dd/mm/yy hh:mm:ss") returned "01/01/01 00:00:00".

  4. #4
    ^:^...ANGEL...^:^ wrack's Avatar
    Join Date
    Mar 2002
    Location
    Melbourne, AUSTRALIA
    Posts
    2,695

    Thumbs up Hmm...

    how about changing it to text I mean CStr function...

    give it a go and I hope it should work...

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    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.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    ah, i think i found a solution. i just went to File -> Report Options and chose "Convert Date-Time Field: To Date".

  7. #7
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478

    And what is the result.

    Did it work ??
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    yep

  9. #9
    Addicted Member
    Join Date
    Dec 2001
    Location
    MD
    Posts
    182

    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.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    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
  •  



Click Here to Expand Forum to Full Width