COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: phoenixfire on 19 Jan 2009 01:20:11 PM

Title: Date time to Date
Post by: phoenixfire on 19 Jan 2009 01:20:11 PM
Hello,
Can someone help me out here?
If I need to convert Date-Time Stamp to a Date stamp, how can I do it?
The prompt page has a date-time parameter. But this parameter needs to be displayed on the report page as only a date (without the time).
thanks in advance
Title: Re: Date time to Date
Post by: jshanks on 19 Jan 2009 03:24:10 PM
Hello:

There are several methods you can use to accomplish this:

1.  Set the data item format for the datetime column to "Date".  This changes the format of the display only.

2.  Create a calculated column that converts the datetime to a date within your report query:

     cast([date_column], date)

3.  Use a function that is native to your database to convert from datetime to date:

     Oracle:  TO_DATE([date_column], 'DD-MM-YYYY')
     
     SQL Server 2005:  DATEADD(dd, 0, DATEDIFF(dd, 0, [date_column]))
Title: Re: Date time to Date
Post by: phoenixfire on 19 Jan 2009 03:46:10 PM
Thank you for your reply. I have actually tried all of these methods. But these work only for query items, not for parameters. If I enter say start date 01-01-2009 12.00 AM in the prompt page, it still shows up as Jan 1 2009, 12:00 AM.

Have you used these methods for parameters before?
Title: Re: Date time to Date
Post by: jshanks on 19 Jan 2009 05:21:50 PM
Is your parameter required?  If so, you can create a query item with the following calculation: cast(?Parameter1?, date) and then place that query item in your report.

Cognos does supply some data type conversion functions that can be used on Layout Calculations.  However, I was not able to get them to work in my test report.
Title: Re: Date time to Date
Post by: phoenixfire on 19 Jan 2009 11:04:54 PM
Hello jshanks,
Will try this method tomorrow and let you know...thank you for the effort either way.
Title: Re: Date time to Date
Post by: sandeep8000861 on 05 Mar 2009 07:36:52 PM
phoenixfire:

Please include each of your parameters in a separate data item and use the filters on these new data items. This is how i overcame the issue.
This will work for you, i think. Worked for me, though!

jshanks:
Thanks very much. :-)