Using Date Edit Masks

When you print dates, you can format them with an edit mask. For example:

print &order_date () edit 'Month dd, YYYY'

This command prints the order date in the specified format. The name of the order date month is printed, followed by the day of the month, a comma, and four-digit year. SQR for PeopleSoft provides an extensive set of date edit masks.

See PRINT.

If the value of the date value being edited is March 14, 2004 at 9:35 in the morning, the edit masks produce the following results:

Edit Mask

Result

Notes

dd/mm/yyyy

14/03/2004

NA

DD-MON-YYYY

14-MAR-2004

NA

'Month dd, YYYY.'

March 14, 2004.

An edit mask containing blank space must be enclosed in single quotes.

MONTH-YYYY

MARCH-2004

The name of the month in uppercase, followed by the 4-digit year.

HH:MI

09:35

NA

'HH:MI AM'

09:35 AM

Meridian indicators. An edit mask containing blank space must be enclosed in single quotes.

YYYYMMDD

20040314

NA

DD.MM.YY

14.03.99

NA

Mon

Mar

The abbreviated name of the month.

Day

Thursday

The day of the week.

DY

THU

An abbreviation for the day of the week.

Q

1

Quarter.

WW

11

The week of the year.

W

2

The week of the month.

DDD

74

The day of the year.

DD

14

The day of the month (1–31).

D

3

The day of the week (Sunday is 1).

EY

Please see below

The Japanese imperial era (Meiji, Taisho, Showa, Heisei).

ER

16

The year in Japanese imperial era.

The result for EY is:

Field or Control

Definition

symbol

Japanese Imperial Era

Note: The MON, MONTH, DAY, DY, AM, PM, BC, AD, ER, EY, and RM masks are case-sensitive and follow the case of the mask that is entered. For example, if the month is January, the Mon mask yields Jan and MON yields JAN. All other masks are case-insensitive and can be entered in either uppercase or lowercase.

If the edit mask contains other text, it is also printed. For example:

print &order_date () edit ’As of Month dd, YYYY’

This command prints the As of March 14, 2004 string if the order date is March 14, 2004. Because the words As of are not recognized as date mask elements, they are printed.

A backslash forces the character that follows into the output. This technique is useful to print text that would otherwise be recognized as a date mask element. For example, a mask of The \mo\nth is Month results in The month is March as an output string. Without the backslashes, the output string would be The march is March. The second backslash is needed because n is a valid date edit mask element.

In some cases, combining date edit mask elements can result in ambiguity. One example is the 'DDDD' mask, which could be interpreted as various combinations of DDD (day of year), DD (day of month), and D (day of week). To resolve such ambiguity, use a vertical bar as a delimiter between format elements. For example, DDD followed by D can be written as DDD|D.

In addition, national language support is provided for the following masks: MON, MONTH, DAY, DY, AM, PM, BC, and AD.