If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Disable selecting holidays (date prompt)

Started by stancho, 14 Jan 2011 02:41:29 AM

Previous topic - Next topic

stancho

Hi all,

I have some reports with DatePicker prompts.
How can I create something like custom calendar in Report Studio (using javascript or some cognos techniques)?
I want to disable selecting holidays (ex. Saturdays and Sundays). I also would like to disable selecting custom national holidays (but only for Saturdays and Sundays would be enough).

If it's not possible to disable these values I would like if somebody choose Saturday the report will show the data for the last working day (ex. Friday).

Any ideas?

BR,
Stancho

Lynn

Do you have a date dimension that identifies work days vs. non-work days? One possible option is to use a value prompt control instead of a date picker that would only present the valid days. Not terribly elegant, I realize. This would not be a good idea if you have tons of dates to choose from.

If you stick with the date picker, can't disable the days (don't get me started with JS), and don't have a date dimension then you can modify your filter condition in the report to account for saturdays and sundays:

Create a data item "filterDate" in the query:
if ( _day_of_week(?PickDate?,1) in (6, 7) )
then ( _add_days(?PickDate?,5-_day_of_week(?PickDate?,1)) )
else ( ?PickDate? )


The above says if the day of the week selected is Saturday (6) then back it up by one day (5 - 6). If it is Sunday (7) then back it up by two days (5 - 7). Otherwise the date is fine as is.

Set the filter condition:
[YourDateItem] = [filterDate]

If you have a date dimension that identifies work days vs. non-work days and also has an attribute for the previous work day then you are a lucky SOB and should run out immediately to buy a lottery ticket.

stancho

Lynn thanks for this answer!

I need Date Picker. Because I have a lot of days (years).

I have two quensions about your solution:

1. If I choose 02.06.2010 If I set:
( _add_days(?ForDate?,-1) ) the date will be 01.06.2010 00:00:00
But If use ( _add_days(?ForDate?,(... - _day_of_week(?ForDate?,1))) ) the date will 01.06.2010 (not a datetime)?

2. Is there a way to use this filter globally or I should add it in every query in every report?

Thanks,
Stancho

Lynn

Hi Stancho,
I guess you don't have a date dimension to work with...

I'll try to answer your questions:
1. Not sure I understand exactly what your issue is, but assuming you don't need users to specify a time, then use a Date Prompt and NOT a Date & Time Prompt. If you use the Date Prompt control then you shouldn't see timestamps. That said, what is the data type in your database that you'll be comparing the selection to? If it is date time then you'll want to cast it to a date only in order to compare apples with apples.

2. I don't know what queries you have in your report but probably you'll need it in all of them. If you have two queries joined together to form a third, then possibly you'd only need the filter in the two base queries and not in the joined query. There isn't a global approach as far as I know.

Good luck!

melee

Quote from: Lynn on 14 Jan 2011 08:00:10 AM
can't disable the days (don't get me started with JS)

Lynn, now that you're my COGNOISe JS pal, I have an idea to solve this quickly and elegantly.

Check out this concept:

1. Create two text value prompts, one for dateBegin and one for dateEnd, or just date if you only need a single day. Create the appropriate filter on the hidden prompts
2. Using JS, set their display:none to hide them
3. Use the jQuery UI datepicker (http://jqueryui.com/demos/datepicker/) on an empty div to create a calendar
4. Add holidays to the function (not the prettiest part, see http://stackoverflow.com/questions/2921848/disable-list-of-holidays-in-jquery-date-picker), then when a date is selected, populate the hidden prompt from step 1 with that information
5. Submit.

I'd be happy to detail this step-by-step if it seems helpful - it'd actually be pretty elegant.
6.

Lynn

Quotemy COGNOISe JS pal
:D

I am sure Stancho will appreciate some knowledgeable help on the JS options for this!

I couldn't even write correct syntax for the joke JS I did in the other thread but decided poetic license ought to apply even to JavaScript.

MFGF

Quote from: Lynn on 14 Jan 2011 10:36:54 AM
I couldn't even write correct syntax for the joke JS I did in the other thread but decided poetic license ought to apply even to JavaScript.

What???  It was a joke?
Meep!

Lynn

Quote from: MFGF on 14 Jan 2011 11:21:32 AM
What???  It was a joke?

MF, the JS I gave you was not a joke.

I, uh, was referring to a completely different thread on a totally different forum  ;) ::)

melee

#8
Ok, I've attached the report. Feel free to give it a go (we're running 8.4).

You'll need to get the CSS file from jqueryui.com - very easy though.

I posted a (rushed) tutorial on the whole thing here:

http://nicbertino.com/?p=41

stancho

melee, thanks a lot for this.

I will check it now!

BR,
Stancho