locked
Time parameter values RRS feed

  • Question

  • User1964723493 posted

    I have a crystal report that has a date range and a time range. I simply want to know how to pass the time parameter in a ASP.NET web application.

    For example I already know how to pass date:

    parameterField.CurrentValues.AddRange(CDate(st_date.Text), CDate(en_date.Text), RangeBoundType.BoundInclusive, RangeBoundType.BoundInclusive)

    How do I pass a time value over?

    Thank you in advance, 

    Wednesday, July 14, 2010 8:07 AM

Answers

  • User1224194097 posted

    you can use DateTime for that

    parameterField.CurrentValues.AddRange(
    DateTime.Parse(st_date.Text), 
     DateTime.Parse(en_date.Text), 
    RangeBoundType.BoundInclusive,
     RangeBoundType.BoundInclusive)



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 14, 2010 11:48 AM

All replies

  • User1224194097 posted

    you can use DateTime for that

    parameterField.CurrentValues.AddRange(
    DateTime.Parse(st_date.Text), 
     DateTime.Parse(en_date.Text), 
    RangeBoundType.BoundInclusive,
     RangeBoundType.BoundInclusive)



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 14, 2010 11:48 AM
  • User1964723493 posted

    It doesn't give me an error but doesn't return any results either. I know I have data in that time range as I can do it within Crystal Designer.

    This is what I have in my code:

  • DateTime.Parse(st_time.Text),    
  •  DateTime.Parse(en_time.Text),    
  • RangeBoundType.BoundInclusive,   
  •  RangeBoundType.BoundInclusive)</

    st_time.text = "08:00:00"

    en_time.text = "17:00:00"

     

Wednesday, July 14, 2010 12:38 PM
  • User1224194097 posted

    I am not sure about the data type in the report

    but you can try this in your procedure

    select Convert(varchar,getdate(),8) 

    to get the time as string and pass values to the report as string

    which should basically compare string to a string

    does that make sense??

    you may have to verify database 

    Wednesday, July 14, 2010 12:52 PM
  • User1964723493 posted

    I appologize for not explaining enough. In my report, the parameter is a datetime and  the field type is a datetime as well.

    Wednesday, July 14, 2010 12:58 PM
  • User1224194097 posted

    That OK,

    honestly, I have never tried with DateTime Parameter Type if it is not a complete date. 

    another alternative is using String type to check for a string

    check these formats if it works

    select CONVERT(VARCHAR,Getdate(),108)
    select CONVERT(TIME,CONVERT(VARCHAR, Getdate(),108))

    I am sure this might be an issue of data type conversion.

    please try that and post your error.

    Wednesday, July 14, 2010 1:15 PM
  • User1964723493 posted

    I finally got it working...

     

    This is what I used for code:

    parameterField3.CurrentValues.AddRange(DateTime.Parse(st_time.Text), DateTime.Parse(en_time.Text), RangeBoundType.BoundInclusive, RangeBoundType.BoundInclusive)

    In my Crystal Reports record selection, I used

    time({Table.EventTime}) >= time(minimum({?Time})) and
    time({Table.EventTime}) < time(maximum({?Time}))

    What really messed me up was the fact that I didn't clear my parameter value. When I added parameterField3.CurrentValues.Clear() to my subroutine then all was well! :)

     

    Thanks for the help sansan.
     

    Wednesday, July 14, 2010 3:25 PM