Show TOC

Background documentationValid Time Pattern Strings

 

This topic describes how to express the date and time format (the time pattern string) for the DATE_TIME variable.

For example, in Next Number Maintenance, you can use the DATE_TIME variable to include date and (or) time in a numbering scheme definition.

The syntax is as follows, where timepatternstring is described in this topic: %DATE_TIME.[timepatternstring]%

Limitations for Next Numbering

When the DATE_TIME parameter is used to define the next numbering pattern for SFC numbers, the numbers generated must conform to the rules for valid SFC numbers. The symbols described below are valid for use in the timepatternstring of the DATE_TIME.[timepatternstring] variable, but you must exercise caution in creating the patterns; otherwise, their use can generate strings that are not valid SFC numbers.

The number of characters in an SFC number cannot exceed 128. A pattern containing an invalid pattern character will result in an error during formatting or parsing.

Note that all generated SFC numbers are shifted to uppercase.

Valid Characters in a Time Pattern String

The following table shows the valid characters (symbols) that can be used in the time pattern string (timepatternstring):

Symbol

Meaning

Presentation

Example

G

era designator

Text

AD

y

year

Number

2010 (yyyy in string)

M

month in year

Text* or Number

July or Jul or 07

d

day in month

Number

10

h

hour in am/pm (1–12)

Number

12

H

hour in day (0–23)

Number

0

m

minute in hour

Number

30

s

second in minute

Number

55

S

millisecond

Number

978

E

day in week

Text*

Tuesday

D

day in year

Number

189

F

day of week in month

Number

2 (2nd Wed in July)

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

24

K

hour in am/pm (0–11)

Number

0

z

time zone

Text*

Pacific Standard Time or PST

Effect of the Symbol Count on Formatting

The count of pattern letters determines the format, as follows:

Presentation

Affect of the Count of the Symbol

Text

The number of pattern letters controls whether the full form or abbreviation (if one exists) is used:

  • If four or more pattern letters, the full form is used

  • If less than four pattern letters, the short or abbreviated from is used, if one exists

Number

The number of pattern letters controls the minimum number of digits. Shorter numbers are zero-padded to this amount. The handling of the year (y) is a special case:

If the count of y is 2, the year is truncated to 2 digits.

Text and Number

The number of pattern letters controls whether a number or letter is used.

If the number is 3 or over, use Text, otherwise use Number.

Example

The following are examples of date formatting patterns for DATE_TIME and the resulting output:

Pattern

Result

yyyy MM dd G hh mm ss zzzz

2008 11 12 AD 06 56 00 EASTERN EUROPEAN TIME

EEE MMM d yy

MON NOV 12 07

h mm a

7 00 PM

K mm a z

7 02 PM EET

Note that the examples above illustrate a wide range of possibilities for expressing dates using DATE_FORMAT, but as stated earlier, not all options are suitable for use in defining next numbering.