When my report in run, it will run with default to yesterday's date (using Default Selection 1900-01-01 an unused date, in Filter check for this unused date and replaced it with Yesterday date). My parameter Date at this point is still the default 1900-01-01.
In Cognos Viewer, there is a prompt for date entry so user can select other days.
In my report header, I used a Layout Calculation to display the Date selected. I would have to put in checks in report expression to trap the parameter Date since the parameter Date is 1900-01-01 when the report is first run.
Report expression:
-------
if
( ParamDisplayValue('parameter_date') = '1900-01-01' )
then
( date2string( _add_days(Today(), -1) ) )
else
( ParamDisplayValue('parameter_date') )
------
I kept getting RSV-VAL-0002 Invalid expression ---> I think the syntax is working, just don't understand why its giving me error.
I posted my question on another website and someone provided this solution (some reason I cannot respond which is why I am posting in this website)
This solution does not show error but it does not display the date, it just displays nothing.
-----------------------------
( ParamDisplayValue('parameter_date') = '1900-01-01' )
then
THEN (number2string(string2double(date2string(Today ())) -1 ))
else
( ParamDisplayValue('parameter_date') )
----------------------------------
Please help - I have been tossing with this problem almost the whole day and getting nowhere.
Thank you.
_add_days work with timestamps, date2string needs a date. Try the following:
date2string(timestamp2date( _add_days(date2timestamp(Today()), -1) ))
Hi PaulM ...thank you so much - you have saved day :) It works - I have spent so much time yesterday trying different options :-\ but nothing would work.
Another question regarding formatting the date -
It is displayed as '2011-06-20' and I would like to format to '20-Jun-11' or in general how I can format the date to any display type?
Thank you.
At this point I would change it to display as a date, then use the data format on the text object.
if
( ParamDisplayValue('parameter_date') = '1900-01-01' )
then
(timestamp2date( _add_days(date2timestamp(Today()), -1) ))
else
( string2date(ParamDisplayValue('parameter_date') ))
Instead of returning a string, that will return a proper date which you can then format any way you want.
Thank you so much once again PaulM - my problem is totally resolved. Summer starts today I think -- Happy Summer :D