COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cac416 on 01 Feb 2010 08:54:20 AM

Title: Date Format
Post by: cac416 on 01 Feb 2010 08:54:20 AM
I'm trying to format a date/time field as a date.  I tried casting it as a date but ended up with the format 'April 21, 2009'.  I need the format to be '4/21/2009'

Any suggestions?

Thanks!
Title: Re: Date Format
Post by: Sreeni P on 01 Feb 2010 12:08:38 PM
Format the date using 'data format' option from properties, in that select the 'date' from left side drop down . in that date select 'data style' as 'short' and default 'date ordering' as 'day,month,year' hope this helps for ur problem
Title: Re: Date Format
Post by: RobSil on 01 Feb 2010 01:29:18 PM
Alternatively you could rely on patterns.  Appendix H in the Report Studio user guide (PDF format) lists the letter meanings.

Basically you select the item, then Data -> Data Format -> Choose Date, then find the pattern field and type in your pattern.  Each letter in the appendix is a place holder for a date value.

So for example...
4/21/2009 would be...

d/MM/yyyy

(day, Month Month, Year Year Year Year)
Each letter in the pattern is 1 digit or character position that will be used.  Note that capital vs. lower case matters as 'd' is day in month, vs. 'D' which is day in year.

To ensure that the day is 05 vs. 5, use 2 d's.



Title: Re: Date Format
Post by: imts on 02 Feb 2010 03:37:53 AM
If u r using Oracle then u can go for to_char( <datetimeexpression> , 'DD/MM/YYYY') function.

-TS