Date properties
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 type | Description | Reference to time zone and locale | Internal representation | Example |
Date | Day of the Gregorian calendar | ❌ | 20201214 (yyyyMMdd) | December 14, 2020. |
TimeofDay | Time of day, up to a second | ❌ | 153025 (HHmmss) | 25 seconds after 3:30 P.M. |
DateTime | Date and time, up to a millisecond | ✔ | 20201016T032300.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.
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.
Expression | Meaning |
| December 15, 2018 |
| 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.
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", "", "")
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", "", "")
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.
Vendor | Date | TimeofDay | DateTime |
Oracle | VARCHAR2(8) | TIMESTAMP | DATE |
IBM Db2 | DATE | Db2 VARCHAR(8) | Db2 TIMESTAMP |
Microsoft SQL Server | Not available | Not available | DATETIME |
PostgreSQL | Not supported; use VARCHAR(8) | Not tested | Not tested |
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.
Previous topic Configuring the Thai calendar Next topic Configuring actionable icon controls