There are a few ways I like to do this. First I'll show you my preferred JavaScript-free way of doing it. In this example I'm using two date-range prompts, but this could easily be switched with separate from-to prompts for both.

The period selector prompt looks like this:

In this case the periodselector has logic to handle the filters for the other periods, with special cases for All Data, and the two date ranges.
The filter in the report query looks like this:
#case prompt('PeriodSelector','token')
when 'DateRange' then '[C].[C_Great_outdoors_sales_data_module].[page_7].[Date_] in_range ?DateRange?'
when 'DateRangeShipped' then '[C].[C_Great_outdoors_sales_data_module].[page_2].[Date_ship_date] in_range ?DateRangeShipped?'
else prompt('PeriodSelector','token')
end#
I also have a similar macro statement inside the one of the data items in the query as well:
#case prompt('PeriodSelector','token')
when 'DateRange' then '[C].[C_Great_outdoors_sales_data_module].[page_6].[Order_date]'
when 'DateRangeShipped' then '[C].[C_Great_outdoors_sales_data_module].[page_6].[Ship_date]'
else '[C].[C_Great_outdoors_sales_data_module].[page_6].[Order_date]'
end#
This lets the end user select how they want to view their data, and if they select a date range prompt it will ignore the other.
This works, but it still leaves the problem of the date ranges being visible. I do have a solution (yes in Cogbox) to solve it so it looks like this:

This uses my performActions script with the following configuration:
{
"Control": "PeriodSelector",
"Start on load": true,
"Actions": [
{
"type": "setDisplay",
"display": false,
"name": "DateRange"
},
{
"type": "setDisplay",
"display": false,
"name": "DateRangeShipped"
},
{
"type": "setDisplay",
"display": true,
"name": {
"type": "promptUse",
"name": "PeriodSelector"
}
}
]
}
Basically every time the periodselector is changed it will hide both date range prompts, then unhide the selected value. If it doesn't find it, like All Data is 1=1, it simply does nothing. You can replicate this by writing a JS control to do exactly the same thing. Set a validator on the periodPrompt prompt that hides both blocks, then unhide them with getControl(values[0].use).
Something along the lines of
oControlHost.page.getControl('PeriodPrompt').setValidator((values)=>{
oControlHost.page.getControl('DateRange').setDisplay(false);
oControlHost.page.getControl('DateRangeShipped').setDisplay(false);
oControlHost.page.getControl(values[0].use)?.setDisplay(true);
})
The attached report xml has two prompt pages, one without the custom control and one with. If you don't have the premium cogbox, just delete the second prompt page to get it working.
------------------------------
Paul Mendelson
------------------------------
Original Message:
Sent: Wed February 22, 2023 07:02 AM
From: Krista Thijsbaert
Subject: Report with 2 date prompts
Hi
I am trying to create a report (Cognos 11.2.2) with 2 different from-to date prompts on the prompt page.
The date prompts are optional and must be used seperate.
How can I default uncheck the checkbox on the date prompt?
------------------------------
Krista Thijsbaert
------------------------------