Date

Date is a text function that returns the date and time that an online report is populated with data, or the date and time that a snapshot report is saved. The date and time is retrieved from the report server and corresponds to the country in which the report server is located. You can use Date in a text box, text cell, or a row or column heading.

Note:

The date and time format vary by locale. The examples in this topic are examples for the US.

Syntax:

<<Date("format,TimeZoneId")>>

Argument Description

format

Defaults to the user preference for date/time. Valid values are those accepted by Java SimpleDateFormat, or "user" or empty ("user").

Date and time format characters are case-sensitive.

TimeZoneId

Valid values are those accepted by Java TimeZone.getTimeZone(), or the server time zone. For example, for TimeZone.getTimeZone() to specify the east coast, enter: "America/New_York".

When using TimeZoneID, enclose the format parameter within quotation marks. This applies only when TimeZoneId is indicated. You do not need to update reports prior to the TimeZoneId enhancement.

Table -14 Date and Time Format Characters

Format Characters Meaning Data Type Example

G

era designator

text

AD

M

month in year

text or number

If the month is July: M displays: 7 MM displays: 07 MMM displays: Jul MMMM displays: July

d

day in month

number

10

h

hour in am/pm (1-12)

number

11

H

hour in day (0-23)

number

22

m

minute in hour

number

30

s

second in minute

number

25

S

millisecond

number

978

E

day in week

text

E: Tue EE: Tuesday

D

day in year

number

189

F

day of week in month

number

<<Date("dd-MMM-yy ‘is the’ F 'th ' E 'of' ‘MMM")>> displays:

24-Dec-02 is the 4th Tue of Dec

w

week in year

number

27

W

week in month

number

2

a

am/pm marker

text

PM

k

hour in day (1-24)

number

23

K

hour in am/pm (0-11)

number

If the time is 3:37PM: 3

z

time zone

text

Pacific Standard Time

y

year

number

2002,02

'

literal text

text

<<Date(" D’the day of ’yyyy")>> displays:105th day of 2002

' '

two single quotes to produce one single quote

text

<<Date("k:mm ‘O’’Clock’ a")>> displays: 6:15 O’Clock PM

Note:

Use 2 single quotation marks to produce a single quote or an apostrophe as in O’Clock (O’’Clock).

Considerations when using format characters:

  • The number or count of format characters determines the format:

    • For text, less than four pattern letters means use a short or abbreviated form, if it exists.

    • Four or more pattern letters means use full form.

    • M or MM means use the month as a number.

    • MMM means use the three-letter abbreviation for the month.

    • MMMM means use the full name of the month.

    For example, if the date is April 24:

    <<Date("dd-M-yy")>> displays 24-4-02

    <<Date("dd-MM-yy)>> displays 24-04-02

    <<Date("dd-MMM-yy")>> displays 24-Apr-02

    <<Date("dd-MMMM-yy")>> displays 24-April-02

  • For numbers, the number of pattern letters is the minimum number of digits. Shorter numbers are padded with zeros. Year is a special case. If you use "yy", the last two digits of the year are displayed, but if you use "yyyy," the four-digit year is displayed.

    For example, if the month is February:

    <<Date("MM-yyyy")>> displays 02-2002

  • All upper and lower case alphabet characters are considered patterns, regardless of whether they are designated format characters.

  • Enclose literal text within single quotation marks. To use a single quotation mark in literal text, enclose the text within single quotes and use two single quotes for the apostrophe.

    For example, the format to print 4 o’clock is:

     <<Date("hh 'o''clock' ")>>

Examples:

Date Format Result

<<Date("d/M/yy")>>

23/3/02

<<Date("d-MMM-yy")>>

23-Mar-02

<<Date("EEEE, MMMM dd, yyyy")>>

Tuesday, March 23, 2002

<<Date("h:mm:ss a")>>

12:52:05 PM

<<Date("h:mm:ss a zzzz")>>

12:52:05 PM Eastern Standard Time

<<Date("EEEE, MMMM dd, yyyy G 'time:' h:mm:ss a zzzz")>>

Tuesday, March 23, 2002 AD time: 12:52:05 PM Eastern Standard Time

<<Date("hh 'o’’clock' a, zzzz")>>

12:00 PM, Eastern Standard Time

Note:

You must use two single quotation marks to produce one single quotation mark in the text of your formatted result.