COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: cognos74 on 25 Aug 2016 02:13:06 PM

Title: date format from Apr 18, 2014 to mmddyyyy
Post by: cognos74 on 25 Aug 2016 02:13:06 PM
Hi,

I am getting date in following format in my report "Apr 18, 2014"  so how to get this into 'mmddyyyy'

Thanks,
Title: Re: date format from Apr 18, 2014 to mmddyyyy
Post by: raj_aries81 on 25 Aug 2016 10:53:37 PM
Goto  "Data Format" option, change the Format Type to Date and set the pattern to MMddYYYY, make sure its not not DD.

Regards
Raj
Title: Re: date format from Apr 18, 2014 to mmddyyyy
Post by: jody915 on 20 Nov 2020 01:11:51 PM
i have a similar issue where i need the date to be in mmddyyyy format, but the data item is not a column on the report so i do not have the ability to change the Data Format.  What expression would is use to remove the '/' from the date?
Title: Re: date format from Apr 18, 2014 to mmddyyyy
Post by: oscarca on 20 Nov 2020 01:42:41 PM
To_date function might work for example:
To_date('2020-11-20','MMddYYYY')
Title: Re: date format from Apr 18, 2014 to mmddyyyy
Post by: adam_mc on 20 Nov 2020 02:16:31 PM
If to_date doesn't work, try the extract function.

Shown below with added cast and substring functions to convert to 8-character result with 2-digit day and month values.

substring(cast(extract(month, [Date]) + 900, char(3)), 2, 2) || substring(cast(extract(day, [Date]) + 900, char(3)), 2, 2) || cast(extract(year, [Date]), char(4))

Hope this helps,
Adam.