COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: mahgar on 13 Feb 2014 06:02:36 AM

Title: Date prompt not working
Post by: mahgar on 13 Feb 2014 06:02:36 AM
I have a Start and End Date date prompt and the [Date of Hire] <= ?End Date? is not working.
If I select End Date = 31/01/2014 not report comes out. But when I select 01/02/2014 then the report shows.
Note: I already casted the dates.

Name      Date of Hire
Employee 1    31/01/2014
Employee 2   31/01/2014
Title: Re: Date prompt not working
Post by: MFGF on 13 Feb 2014 06:15:23 AM
Hmmmm...

You're not using MM/DD/YYYY format by any chance?

MF.
Title: Re: Date prompt not working
Post by: mahgar on 13 Feb 2014 07:22:45 PM
Hi MF,

No, all of our date fields are on TIMESTAMP format (2014-01-31 00:00:00) and weird this is the ">=" is working and the "<=" is not

Thanks

Mahgar
Title: Re: Date prompt not working
Post by: chinnucognos on 14 Feb 2014 01:36:58 AM
i have tried with to_char(start_date,'MM/DD/YYYY') AS Date_of_HIre
then date_of_hire<= ?end_date?..
Have you tried this same....
Title: Re: Date prompt not working
Post by: mahgar on 14 Feb 2014 02:37:59 AM
Hi Chinnucognos,

Here's the report that im expecting:

Detail Filter: [Date of Hire] >= ?pDateofHireFrom? and [Date of Hire] <= ?pDateofHireTo?

If ?pDateofHireFrom? >= 30/01/2014 ---(or 31/01/2014)
and ?pDateofHireTo? <= 31/01/2014 then the expected will show.

Expected Output:
Name             Date of Hire
Employee 1    31/01/2014
Employee 2    31/01/2014

But what happens is, if I select the prompts above there's no report will show.
The report will only show if I change the ?pDateofHireTo? to "01/02/2014" or change it to a day later.
Title: Re: Date prompt not working
Post by: mahgar on 19 Feb 2014 12:51:59 AM
Hi Guys,

Does any of you guys experience the same scenario?

TIA!
Title: Re: Date prompt not working
Post by: Lynn on 19 Feb 2014 09:23:52 AM
You mention in your first post that you already casted the dates, and then later you mention that all your date fields are timestamp data types. What exactly are you casting? Do you use a calendar control for your prompt? Is the time component in the database vs the time component of your prompt affect the result? I suspect the time component and/or incorrect casting are to blame.

As a side note, I'd suggest that between logic is a little cleaner to read since your range is inclusive:


[Date of Hire] between ?pDateofHireFrom? and ?pDateofHireTo?
Title: Re: Date prompt not working
Post by: Francis aka khayman on 20 Feb 2014 01:30:33 AM
explicitly format your dates just as MFGF implied.

reason why 31/01/2014 is not working is because it might be an invalid month
01/02/2014 however can be Jan 2, 2014 or Feb 1, 2014 which is always a valid month.
Title: Re: Date prompt not working
Post by: mahgar on 10 Apr 2014 09:41:40 PM
Hi chinnucognos,

I tried your solution as well but it doesn't works fine.


What I did was adding the expression below. The "<=" function doesn't treat my "TO" prompt as timestamp.
It works fine finally.
[Date of Hire] >= ?pDateofHireFrom?
and
[Date of Hire] <= _add_days(cast((?pDateofHireTo?) as TIMESTAMP),1)