DateTime

DateTime is a text function that returns the date and time that a report is populated with data. 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 DateTime in a text box, text cell, or a row or column heading.

Note:

The time zone used in the text function results upon report preview is based on each user's time zone specified in User Preferences.

Syntax:

DateTime("DateFormat","TimeFormat")

Note:

If the DateTime function parameters are left blank, for example, DateTime (), or if "none" is used in both parameters, for example, DateTime (none, none), then the Narrative Reporting User Preferences for Date and Time will be used for the format.

Note:

See Parameters for Text Functions for parameter definitions.

Alternatively, you can specify locale-neutral values for short, medium, long, and full formats: DateTime (short|medium|long|full|none, short|medium|long|full|none). (Do not use quotes when entering these values.) Examples (examples given for the United States):

  • DateTime(short, short): 01/03/2017 1:54 PM

  • DateTime(medium, medium): Jan 03, 2017 1:54:32 PM

  • DateTime(long, long): January 03, 2017 1:54:32 PM PDT

  • DateTime(full, none): Tuesday, January 03, 2017 (Note: the time is not shown.)

  • DateTime(none, short): 1:54 PM (Note: the date is not shown.)

Table 10-9 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

In the United States, if the time is 3:37 PM: 3

z

time zone

text

Pacific Standard Time

y

year

number

2017,02

'

literal text

text

Date(" D’the day of ’yyyy") displays:105th day of 2017

' '

two single quotes to produce one single quote

text

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

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-17

    Date("dd-MM-yy") displays 24-04-17

    Date("dd-MMM-yy") displays 24-Apr-17

    Date("dd-MMMM-yy") displays 24-April-17

  • 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-2017

  • 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/17

Date("d-MMM-yy")

23-Mar-17

Date("EEEE, MMMM dd, yyyy")

Tuesday, March 23, 2017

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, 2017 AD time: 12:52:05 PM Eastern Standard Time

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

12:00 PM, Eastern Standard Time

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