Skip to Content
avatar image
Former Member

Date & Time range for Record Selection parameter

Hi

I am trying to create a record selection formula in Crystal Reports that includes filtering by date & time for reports which run on weekdays (Mon-Fri) at 4pm.

The selection I am trying to achieve is where the report will pick up records created after 4pm on the previous weekday up to the time the report iss run at 4pm. For example Monday's report at 4pm should include any record created after 4pm on the previous Friday up to 4pm on the Monday, Tuesday's report should pcik up records created after 4pm on Mon up to 4pm on Tuesday etc.

I am unsure how to create a formula that will cover the first example of Fri 4pm up to Mon 4pm. Could anyone help please?

Thanks

Jon

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jun 29, 2017 at 08:13 AM

    Try this in record selection

    Yourdatetimefield >= (if weekday(currentdate)= 2 then datetime(year(currentdate-3), month(currentdate-3), day(currentdate-3), 16,0,0) else datetime(year(currentdate-1), month(currentdate-1), day(currentdate-1), 16,0,0))

    and Yourdatetimefield <= datetime(year(currentdate), month(currentdate), day(currentdate), 16,0,0)

    Ian

    Add comment
    10|10000 characters needed characters exceeded