COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: zb12 on 07 May 2009 10:05:10 AM

Title: date formatting error when exporting into excel
Post by: zb12 on 07 May 2009 10:05:10 AM
I have reports that are scheduled to run in single sheet excel format. When the emails are sent and the recipient opens the attachment the report shows the date as what seems like a random set of numbers. However when the data is pasted into an excel spreadsheet the numbers convert to a date. For example 33592=12/20/91. also sometimes I run a report manually and I get the same problem. when i format the cells in excel to show is dates the numbers are converted. I have set the data format in cognos as a date format but the problem persists. Any ideas as to what's going on and how to fix it?
Title: Re: date formatting error when exporting into excel
Post by: johnpenna on 07 May 2009 11:17:57 AM
cast as a date

cast([Data item],date)
Title: Re: date formatting error when exporting into excel
Post by: Gopinath on 08 May 2009 01:05:36 AM
try placing the Data item inside a block.
Title: Re: date formatting error when exporting into excel
Post by: dumbell on 11 May 2009 05:52:23 PM
did you try to_char
Title: Re: date formatting error when exporting into excel
Post by: zb12 on 12 May 2009 08:19:45 AM
i tried the first two and i still get the same thing. how do i use _char?
Title: Re: date formatting error when exporting into excel
Post by: CognosPaul on 12 May 2009 08:38:23 AM
The problem you're having is Excel converting the dates to numbers. Excel handles numbers by counting the number of days since January 0, 1900. 1/1/1900 = 1, 33592=12/20/91, 39945 = 5/12/09. This leads me to believe it's an Excel issue. Cognos is sending it in DATE format, Excel is reading it wrong.

A workaround might be formatting the date as text.

cast ([Date],VARCHAR(10))
Title: Re: date formatting error when exporting into excel
Post by: zb12 on 12 May 2009 08:40:13 AM
formatting the date as text in excel?
Title: Re: date formatting error when exporting into excel
Post by: zb12 on 12 May 2009 08:43:32 AM
the error is also occuring when i send the report in single sheet and it is opened in html in IE.
Title: Re: date formatting error when exporting into excel
Post by: CognosPaul on 12 May 2009 08:44:14 AM
In the query level in Cognos.
Title: Re: date formatting error when exporting into excel
Post by: zb12 on 12 May 2009 08:52:15 AM
the weird thing is that when i open the html attachment, that was sent in the email from the report i scheduled, and then i copy and paste the date striaght into excel the data converts itself to a date instead of the number of days since 1900. i'm confused.

i tried setting the format as text in cognos and still the html attachment is not formatted correctly. i have just been telling the recipeints to copy and paste the data into excel as the only fix?

Thanks for your help
Title: Re: date formatting error when exporting into excel
Post by: CognosPaul on 12 May 2009 09:21:29 AM
Did you change the query item, or just the data format in the report? My suggestion was to modify the query item.
Title: Re: date formatting error when exporting into excel
Post by: zb12 on 12 May 2009 12:05:01 PM
oh i just changed the data format. I'll go back and try your suggestion