Quando omni flunkus, mortati. Die dulci fruere.

| Subscribe via RSS

Friday, January 23, 2009

Set default "from date" in a date range prompt

|

I discovered recently that you can't set the "default" of any Cognos prompts to a dynamic (non-static) value.

Let me explain: In my example, within Report Studio, I needed to change a date range prompt. I needed the "from date" to default to the beginning of the current year (i.e. Jan. 1, 2009), and the "to date" to default to the current date (today's date).

The best (non-Javascript) method of handling this as I discovered, is to create a radio-button prompt with the static choices of "From Start of Year" and "Select From Date". Next, I set these to values of 1 and 0 respectively. Finally, in the filter, I used the following logic:

(?DateType?=1 AND [MyDate] > _make_timestamp(extract('year',currentdate),01,01))

OR

(?DateType?=0 AND [MyDate] > ?FromDate?)

1 comments:

Robert said...

so you would have 2 filters? or just choose between using 1 or the other of "
(?DateType?=1 AND [MyDate] > _make_timestamp(extract('year',currentdate),01,01))
OR
(?DateType?=0 AND [MyDate] > ?FromDate?)" ?