COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Kory on 10 Aug 2006 11:33:17 AM

Title: ConvertCharFieldToDate
Post by: Kory on 10 Aug 2006 11:33:17 AM
Hi,
I need to convert a character field to a date field in report studio. I am putting this code in the expression editor box ==> cast([Shipping Date],DATE) and I get an error. What am I doing wrong? The consultant that built the package I am using defined this field as a char. The date will only display like this 20060810. My boss wants it to display like this August 10 2006. Can someone please help me with this?
Thank you in advance!
Title: Re: ConvertCharFieldToDate
Post by: Boris-A on 10 Aug 2006 01:53:44 PM
It would help to know the kind of database you have behind that (for the data, not the content store).

???
Title: Re: ConvertCharFieldToDate
Post by: Kory on 10 Aug 2006 02:34:17 PM
Hi Boris,
SQL Server
Title: FrameworkManager
Post by: Kory on 10 Aug 2006 03:04:04 PM
Is it okay to go into Framework Manager and change the Data Type to Date Time and usage to Identifier without doing any harm?
Title: Re: ConvertCharFieldToDate
Post by: Blue on 14 Aug 2006 10:39:22 AM
No you can't just change the datatype in FM.  In fact I don't think FM will let you.

Create another column in the query subject that will a DATETIME column.  Modify the SQL to use CONVERT(), CAST() or DB specific data functions to convert the CHAR col to a DATE.

In Oracle I have:

Select MONTH_NUM,
       To_date(To_char(MONTH_NUM) || '01','YYYYMMDD') As MONTH_BEGIN_DT,
       CURRENT_IND
From  [EPM].PS_TNT_CURR_MONTH
Title: Re: ConvertCharFieldToDate
Post by: Kory on 16 Aug 2006 02:35:35 PM
Thank you! I didn't realize I had to drag a query calculation to the report. I was trying to use the cast_timestamp function in the filter expression box. When the filter box is open there is a list of available functions. I thought if the functions were made available I could use them in that editor.