Hi,
How do I get monthname from a datefield - I have tried the function monthname(fieldname) but it comes up with an error. I am using Report Studio v8.2. The source database is Access. Appreciate if anyone can help me on this...
Error Message:
RQP-DEF-0177
An error occurred while performing operation 'sqlPrepareWithOptions' status='-69'.
Cheers,
Aji
First of all, create a data item that extracts month using extract (month, [Date Field]). This will give you 1, 2 3, ... depending on Jan, Feb, Mar, ...
Then, create a case statement such as
case
when [data item] = 1 then 'January'
when [data item] = 2 then 'February'
.
.
.
when [data item] = 11 then 'November'
else 'December'
end
This will replace the extracted month to month names.
Thanks Suraj but this is what I had done as a workaround. I thought there would be an easy way out by just specifying monthname(date field). This works fine directly from MS Access query. Though Cognos includes this function as part of the Access function list, it doesn't seem to work. Have you got this function to work directly from Cognos?
We have month indicator in our date field that we can compare numbers with to get month name. So we don't have to write that case statement.
to get month type in this expression
extract(month,date expression)
If you just want to show the month name from your date field, use the Format property of the date value and you can take control of which parts of the date are displayed and how they are displayed.
Regards,
MF.