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

Regarding Date Prompt

Started by FATIMA, 19 Aug 2008 01:36:20 AM

Previous topic - Next topic

FATIMA

Hi ,

My requirement is to display prompt with default date which is to be the last business day of the previous month.Also user should be able to change this default date as per requirement.

Can anyone help me on this???


Thanks& Regards,
Fatima S.

blom0344

Quote from: FATIMA on 19 Aug 2008 01:36:20 AM
Hi ,

My requirement is to display prompt with default date which is to be the last business day of the previous month.Also user should be able to change this default date as per requirement.

Can anyone help me on this???


Thanks& Regards,
Fatima S.

Base the prompt on a query like:



SELECT MAX(SOMEDATE) FROM SOMETIMETABLE WHERE _DAY_OF_WEEK(SOMEDATE,1) < 6 AND
SOMEDATE < _FIRST_OF_MONTH(CURRENT_DATE)



Assuming that you have a general date/time table in your database/package or another table that stores each date at least once.

You can build the query by Cognos means by setting the aggregate type on SOMEDATE to maximum and adding a filter that stores the WHERE part of the SQL


FATIMA

Hi ,

My requirement is to display Date Prompt with default date as the last business day of the previous month

Regards,
Fatima S.

goose

Hi Fatima

You can only achieve what you want via javascript unfortunately. What version of Cognos are you using?

Cheers
Angus


blom0344

Quote from: FATIMA on 19 Aug 2008 05:50:47 AM
Hi ,

My requirement is to display Date Prompt with default date as the last business day of the previous month

Regards,
Fatima S.

Perhaps I misread your request, but why would my query-example not show the correct date in the prompt?

Angus, can you explain what the Javascript would do?

FATIMA

Hi Bloom 8344,
Pls tell me how can i achieve it in Date Prompt?

Hi Angus,
Now am using Cognos 8 for creating reports using dummy datas..But in my Project, i have to use Cognos 8.3 Version.

Regards,
Fatima S.

goose

blom0344 Fatima wants to specifically use the Date Prompt control in which case there is no option to supply a query subject etc. One option is fetch the requried data (like in your sql) via a Value Prompt and make the Control hidden, then after the page has loaded set the Date Prompt value via javascript.

Fatima you can set the default value via javascript I will post an example asap.

blom0344

#7
Fatima,

The Date prompt is fed by an associated query. The trick is to design the query so that it will yield the last business day of the previous month. (as per code given)
You also need to pick a value-prompt to show the date in, cause a regular date/time prompt has no query associated with it.
Furthermore you need to pick a date as dataitem from a table that stores a continous set of dates (like a calendertable)

edit:

Java-script seems to be a bit of a risk. From what I gathered Java code may stop functioning when migrating to newer Cognos versions. I do not think Cognos will guarantee its use in future versions.

goose

Maybe Im missing something here but I think Fatima's requirement is a Date Prompt control as in the physcial Date Prompt (calendar control) and not a Value Prompt (dropdown box) with dates in it... Fatima which is it?

If you are happy with using a Value Prompt with dates in it then blom0344 approach is perfect. If you must have the Date Prompt (calendar control) you will have to use javascript.

FATIMA

I Should use Date Prompt for my Requirement..
Plz send me the Jave script if possible...

Regards,
Fatima S.

mgraham

Create an html item as follows. Modify it to use your report item name and modify to the correct logic. Place the item at the end of the page so it is rendered after your report item:


<script>
    var a = document.getElementsByTagName("A");
   
    for(var i=0;i<a.length;i++){
                if(a.href.split("#")[0] == 'javascript:checkBoxListColumnsPrompt.selectAll()'){
           a.parentNode.removeChild(a);       
   }
    }

function subtractDay ()
{
var dtToday = new Date();

//Following 2 lines for For Testing weekend/Monday dates
//dtToday.setDate(6);
//alert(dtToday);

var dtTodayWeekday = dtToday.getDay();

// NOTE 86400000 = 24 hours * 60 (minutes per hour) * 60 (seconds per minute) * 1000 milliseconds per second)

if (dtTodayWeekday == 1){
  var dtYesterday = new Date( dtToday - 259200000);
}
else {
  var dtYesterday = new Date( dtToday - 86400000 );
}
 


  var strYesterday = [dtYesterday.getUTCFullYear(), dtYesterday.getMonth()+1, dtYesterday.getDate()].join("-");

  return strYesterday;
}
//alert (subtractDay());
pickerControlEffDatePrompt.setValue( subtractDay() );

</script>


UseCog

#11
Interesting discussions. Thanks All

Blom : Any idea about adding a default value to list prompt if my source is a cube. I cant be able to use SQL there. my requirement is to load current week into default while loading the page and to load all weeks from calander after that.