Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Date properties

Updated on February 7, 2022

A single application can have users in different time zones, who use multiple work calendars and have different holiday schedules. To support the varied needs of your business, Pega Platform includes different property types that reference time and that you can use with a Date Time control.

Overview of time reference properties

The following table represents the different property types that reference time, and their key characteristics.

Property typeDescriptionReference to time zone and localeInternal representationExample
DateDay of the Gregorian calendar20201214 (yyyyMMdd)December 14, 2020.
TimeofDayTime of day, up to a second153025 (HHmmss)25 seconds after 3:30 P.M.
DateTimeDate and time, up to a millisecond20201016T032300.000 GMT (yyyyMMddTHHmmss.SSS GMT)3:23 A.M. on October 16, 2020 in the GMT time zone

Date properties

You can enter a date using either two or four digits for the year. If the year contains two digits, the system uses an algorithm to determine a century based on the current date. For example, in 2021, the system prefers dates between 2001 and 2100.

Caution: A property of type Date can have a null value. For example, if you use the Property-Set method to set a Date type value from a Text value that is null, then the result is null. However, Java Date operations convert an integer value of 0 to the date 19700101 (January 1, 1970). This Date value may result when Pega Platform evaluates expressions that internally use the Java Date operations.

When you provide a Date literal constant as an entire expression, use double quotes. The following table represents how the meaning of the property changes depending on the notation that you use.

ExpressionMeaning
"20181215"
December 15, 2018
20181215
Integer that the system converts to 20,181,215

TimeofDay properties

You can set a constant TimeofDay value into a rule form by entering either all six digits or omitting the seconds portion.

DateTime properties

When you enter a DateTime value in a rule form, the second and millisecond values default to zero. If you omit the time zone, the system converts the date and time from the current server time zone to the GMT time zone.

If you use a DateTime value, the system can determine a corresponding Date and a TimeofDay value. However, the opposite is not possible. When you use a Date or TimeofDay value, the system can construct multiple differing but correct DateTime values, which depend on assumptions about time zone, daylight savings time, and other considerations.

Formatting

Pega Platform supports multiple formats that your application can use to display dates and times in ways that are familiar to application users. The formats that apply in specific cases depend on the selected non-auto-generated control rule or the configuration of the pxDateTime auto-generated control rule (Rule-HTML-Property rule type) associated with the property or the form and the locale.

Many formats are locale-specific and change automatically based on the value set on each user's workstation, or the locale of a user as recorded in the Operator ID data instance.

For example, the date 20181214 can appear as any of the following:

  • 12/14/18
  • 14/12/18
  • December 14, 2018
  • 14 décembre 2018

The date and time formats rely on version 1.3 of the Unicode Common Locale Data Repository (CLDR).

Time zone and Daylight Savings Time conversions

The Java virtual machine (JVM) on which Pega Platform runs provides the available time zones. The JVM typically uses data provided by the Olson TZ database.

Note: Daylight savings time rules are supplied by Java development kit (JDK) vendors. In a multinode system, it is important that you install the same rules on each node. For details of vendor JDK support of daylight savings time and downloads, see the Oracle knowledge base.

Conversion and comparison of a DateTime value to a Date value

The first eight characters of a DateTime value match the structure of a Date value that is formatted as yyyyMMdd, for example 20180930 represents September 30, 2018.

For example, the Property-Set method converts a DateTime value to a Date value by selecting the first eight characters. When the DateTime value is 20181201T011532.006 GMT, the resulting value for the Date property is 20181201. However, this approach ignores the time zone information in the DateTime value, because the Date value conveys no time zone. You can use the FormatDateTime function to convert a DateTime value to a Date in the following way:

@FormatDateTime(.pyExpireDateTime, "yyyyMMdd", "", "")
Caution: To convert a DateTime value to a Date value, in the time zone of the Pega Platform server, avoid using Date property types in persistent objects, such as work items or assignments, even if your application is used in only a single time zone, unless a time zone value is also stored in another property of the object.

Conversion and comparison of a DateTime value to a TimeOfDay value

The substring of a DateTime value from character position 10 to character position 15 contains a time-of-day value, in the format HHmmss expected by a property that has a Type of TimeOfDay.

Similarly to Date conversion, you can convert or extract this TimeOfDay value from a DateTime value with a Property-Set method. When the DateTime value is 20181201T011532.006 GMT, the resulting value for the Time property is 011532. However, this approach ignores the time zone information in the DateTime value, because the Time value conveys no time zone. You can use the FormatDateTime function to convert a DateTime value to a TimeOfDay value in the following way:

@FormatDateTime(.pyExpireDateTime, "HHmmss", "", "")
Caution: To convert a DateTime value to a TimeOfDay value, in the time zone of the Pega Platform server, avoid using TimeofDay property types in persistent objects, such as work items or assignments, even if your application is used in only a single time zone, unless a time zone value is also stored in another property of the object.

Oracle, Microsoft SQL Server and IBM Db2 compatibility

Because vendors use variations of SQL standards, mappings between Pega Platform data types and database column types vary by vendor. For the PegaRULES database, Pega Platform uses the following mappings.

VendorDateTimeofDayDateTime
OracleVARCHAR2(8)TIMESTAMPDATE
IBM Db2DATEDb2 VARCHAR(8)Db2 TIMESTAMP
Microsoft SQL ServerDATETIME

The Db2 TIME data type does not correspond to any Pega Platform property type. You can use a Db2 VARCHAR(8) to map a Time property to a Db2 column.

When feasible in external Db2 databases, you can use the Db2 TIMESTAMP data type instead of DATE or TIME. If not feasible, use a Pega Platform property type of Text to hold the value, which you can then convert.

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us