There are many ways a report author can format dates and times on a Cognos Analytics report. Sometimes you need to format a date in order to save space on a report.
Here are few examples of how you can apply different formats to the same date.
- January 1, 2019
- Jan 1, 2019
- 01/01/2019
- 1/1/19
Use the Data Format* property to format a date the way you want.
*NOTE: This page focuses on formatting dates, but you can use the same Data Format property to also format times, currency, and other data.
Format Dates with the Data Format Property
- On your report page, select the date object that you want to format.
- In the Properties pane, under Data, click the Data format ellipses.
Use the table below and from the Format type drop-down list, select Date, Time, or Date/Time (depending on what you want to display).
Format type
Default format example
none selected 11/29/11 12:10 AM Date Nov 29, 2011 Date/Time 11/29/11 12:10 AM Time 12:10:59 AM In many cases, the default settings will serve your needs and no further action is needed. If you need to apply additional formatting to your data, proceed to the next section below.
Use the Date Style Property
The Date style property is available in the Date and Date/Time data formats.
Usually, selecting an option from the Date style drop-down list will achieve the formatting you want.
Date Style | Example |
---|---|
Short | 11/29/11 |
Medium (default) | Nov 29, 2011 |
Long | November 29, 2011 |
Full | Tuesday, November 29, 2011 |
If the Date style property doesn't achieve the date format you want, proceed to the next section below.
Use the Pattern Property to Set Advanced Date Formatting
You can use the Pattern property to specify additional date formats.
When you define a pattern, the number of symbols you use affects how the data will appear. There are different rules for text and numbers.
Symbols
In the Pattern field, enter the symbols for the date format pattern you want. Separate the symbols by spaces and punctuation as you want it to appear. Refer to the following table for the most commonly used symbols.
To display... | Symbol | Example |
---|---|---|
day (text) in week | E | E, EE, or EEE produces Tue EEEE produces Tuesday |
day in month | d | d produces 29 |
day in year | D | D produces 333 |
day number in week (1= first day) | e | e produces 2 |
month | M | MM produces 1 MM produces 01 MMM produces Jan MMMM produces January |
week in year | w | w produces 49 |
year | y | yy produces 11 yyyy produces 2011 |
Text
You can specify to show full or abbreviated text.
Number of Symbols | Displays | Example |
---|---|---|
4 or more | full text | EEEE produces Monday |
less than 4 | abbreviated text | EEE produces Mon |
Numbers
The number of symbols you use in a pattern sets the minimum number of digits that will appear on a report. Numbers that have fewer digits than you specify are zero-padded.
For example, if you specify dd for day of month, then the 6th of the month would appear as 06 on your report.
Text and Numbers
For values that can display as either text or numbers, such as months, you can specify which you want to appear. If you specify text, you can also specify if words are abbreviated.
Number of symbols | Displays | Example |
---|---|---|
3 or more | text | MMMM produces January MMM produces Jan |
less than 3 | numbers | MM produces 01 M produces 1 |
Pattern Examples
The following table shows some examples of symbol combinations you can enter in the Pattern field to produce certain results.
Pattern Example | Produces |
---|---|
MMM d | Nov 29 |
MM/d | 11/29 |
EEEE, MMMM dd, yyyy | Tuesday, November 29, 2011 |
EEE, MMM d, yyyy hh:mm a | Tue, Nov 29, 2011 12:10 AM |
Related: