0

I am currently working on an SSRS report and I have to deliver this report two times a day. (At 12 PM and 12 AM). The report has the following parameters. Date: (Picks Today's Date) Beg Hour: (Defaults to 8 i.e. 8AM) End Hour: (Defaults to 18 i.e. 6PM)

When the report first delivers between 12PM to 12:30 PM (Afternoon) Monday, I want the BegHour parameter to set to 8 and EndHour to set to 12. When the report again runs for the second time between 12AM to 12:30 AM (Tuesday morning) to, I want the BegHour to set to 8 and EndHour to 18.

I tried using IIF or CASE statements by passing today as paramter to date functions. But I am having trouble figuring this out. Any help is greatly appreciated. Thank You.

Kashyap MNVL
  • 603
  • 4
  • 13

1 Answers1

1

I think you can set BegHour to 8 by default, since in both cases it is required it to be set to that value.

For EndHour you can use the following expression:

=IIF(
Now.Hour = 0, 18, 12
)

Let me know if this helps.

alejandro zuleta
  • 13,962
  • 3
  • 28
  • 48
  • I appreciate it. I didn't try it yet but I somehow tried this one below: `= IIF(Right(FORMAT(Now,"dd-mm-yyyy hh:mm:ss tt"),2)="AM",18,12)` Basically, I formatted the current time (the time the report runs) and extracted the last two letters from formatted time to check if the report is running during AM time or PM time. – Kashyap MNVL Aug 31 '16 at 02:54
  • I just realised that your solution is even more simple. Thank you @alejandro-zuleta – Kashyap MNVL Aug 31 '16 at 02:59