Skip to Content
0

Date & Time range for Record Selection parameter

Jun 28, 2017 at 03:51 PM

25

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Ian Waterman Jun 29, 2017 at 08:13 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Ian

Thanks for that, that has achieved what I was hoping for, much appreciated.

0