|
Since the introduction of Cognos 10 it's been possible to set default options for a date prompt. But it's also possible to do it without resorting to any code behind the scenes, just by using some static choices and some flexible logic in the filters.
For this example, I want to create a prompt in a prompt page that looks something like this:
For this example, I want to create a prompt in a prompt page that looks something like this:
The options in the upper section are all static choices
Given those options, you can now create a filter that will use them to identify the period needed for the report:
or
(?p_Period? = 'PrevWeek' and [Date] between _add_days (current_date,-7-_day_of_week (current_date,1)) and _add_days (current_date,-1-_day_of_week (current_date,1)))
or
(?p_Period? = 'WTD' and [Date] between _add_days (current_date,-1-_day_of_week (current_date,1)) and current_date)
or
(?p_Period? = 'MTD' and [Date] between _first_of_month (current_date) and current_date)
or
(?p_Period? = 'Yesterday' and cast([Date],date) = _add_days (current_date,-1))
or
(?p_Period? = 'Range' and [Date] between ?p_Begin? and ?p_End?)