How to extract month a from a date and display it as a string in Report studio
How to extract month from a date field and display it as a string in Cognos 8.
Resolving the problem
extract(month,[date data item]) gives the numeric value of a month.(example : 8 for August)
To display it as a string ('August', for example) there are several solutions:
1) Before extracting, change the date format of the date data item to date and date style to Long. Now select 'no' to display years,weekdays and days. Select yes to display months. This when run gives the date displayed as month name.
2) Use a Case Statement
case extract(month,[Order date])
when 1 then 'January'
when 2 then 'February'
when 3 then 'March'
when 4 then 'April'
when 5 then 'May'
when 6 then 'June'
when 7 then 'July'
when 8 then 'August'
when 9 then 'September'
when 10 then 'October'
when 11 then 'November'
when 12 then 'December'
3) Use one of the vendor specific functions depending on the database.
See the attached reportspec using Gosales and Retailers .
More support for:
Cognos 8 Business Intelligence
Software version: 8.3, 8.4, 8.4.1, 10.1, 10.1.1
Operating system(s): Solaris, Windows
Reference #: 1341546
Modified date: 18 July 2012