Format Dates (and Times) in a Report

Introduction

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

  1. On your report page, select the date object that you want to format.
  2. In the Properties pane, under Data, click the Data format ellipses.
    The Data format dialog box appears.


  3. 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 selected11/29/11 12:10 AM
    DateNov 29, 2011
    Date/Time11/29/11 12:10 AM
    Time12:10:59 AM
  4. 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


Usually, selecting an option from the Date style drop-down list will achieve the formatting you want.

Date Style

Example

Short11/29/11
Medium (default)Nov 29, 2011
LongNovember 29, 2011
FullTuesday, 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...SymbolExample

day (text) in week 

E

E, EE, or EEE produces Tue

EEEE produces Tuesday 

day in month

d produces 29 

day in year

D produces 333

day number in week (1= first day) 

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

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:

Date Formats and Functions (IBM)

Comments (0)


Brown Community members, log in to submit a comment.

Top