Search code examples
crystal-reportscrystal-reports-2010crystal-reports-xi

Crystal Reports: Set time


I have a pre-existing Crystal report that uses a time column to output data by hourly intervals.

How do I limit them from 8pm to 8am?

Time(Hour({@DATETIME}),0,0)

Current output of the report


Solution

  • As long as your data field has both date and time data in the field, you will have issues with your record selection needs. So the first thing you need to do is to create a Formula Field that strips the Time data out of the field without the Date data. To do this use the following formula in a new Formula Field.

    TimeValue({@DATETIME})
    

    Now you simply need use the Select Expert to write a Record Selection Formula that evaluates this Formula Field. Assume the Formula Field created above has a name of {@TimeStamp}. The Record Select Formula would look like this:

    {@TimeStamp} in Time (8, 00, 00) to Time (21, 00, 00)
    

    This should allow your report to only select data records where the time stamp portion of your {@DateTime} is between 8am and 8pm for any date. :)